aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/common_api/common_api.ex
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-09-17 14:09:01 +0000
committerlain <lain@soykaf.club>2020-09-17 14:09:01 +0000
commit7c60789ba540b8346c1a642b49c29df213217655 (patch)
tree9df5bb75df8f1344768ebe4d26a14d1043820667 /lib/pleroma/web/common_api/common_api.ex
parentf58262c673616661baf9750c216a07d239ae99c3 (diff)
parent5426eb59976044f88247486da86a91b8f9eb35b5 (diff)
downloadpleroma-7c60789ba540b8346c1a642b49c29df213217655.tar.gz
Merge branch 'develop' into 'nondiscoverable-user-metadata'
# Conflicts: # CHANGELOG.md
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 500c3883e..a8c83bc8f 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