aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2020-08-31 16:48:24 -0500
committerAlex Gleason <alex@alexgleason.me>2020-09-11 14:09:50 -0500
commitf88dc1937e5aa4208143fa68400a5c38a1b9eddf (patch)
tree25a1de7a4328f9c023bb2e3263b0e742ef7c2455 /lib/pleroma/web/common_api/common_api.ex
parent425324aae3d4534bc045466a1cc15653ddfa27d2 (diff)
downloadpleroma-f88dc1937e5aa4208143fa68400a5c38a1b9eddf.tar.gz
MastodonAPI.StatusView.get_user/1 --> CommonAPI.get_user/1
Diffstat (limited to 'lib/pleroma/web/common_api/common_api.ex')
-rw-r--r--lib/pleroma/web/common_api/common_api.ex17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index 5ad2b91c2..d6e9d3d67 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -550,4 +550,21 @@ defmodule Pleroma.Web.CommonAPI do
def show_reblogs(%User{} = user, %User{} = target) do
UserRelationship.delete_reblog_mute(user, target)
end
+
+ def get_user(ap_id, fake_record_fallback \\ true) do
+ cond do
+ user = User.get_cached_by_ap_id(ap_id) ->
+ user
+
+ user = User.get_by_guessed_nickname(ap_id) ->
+ user
+
+ fake_record_fallback ->
+ # TODO: refactor (fake records is never a good idea)
+ User.error_user(ap_id)
+
+ true ->
+ nil
+ end
+ end
end