aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/controller_helper.ex
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2019-09-30 14:28:12 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2019-09-30 19:10:55 +0700
commit3c5ecb70b45ae3db193e58b9a3b4a6100b411e4d (patch)
tree486787fe5011cc8a1e07fbf65445b7c9c5f42d4d /lib/pleroma/web/controller_helper.ex
parente7aef27c0011d3fd0b569ebdb9196a1e011eae5d (diff)
downloadpleroma-3c5ecb70b45ae3db193e58b9a3b4a6100b411e4d.tar.gz
Add PleromaAPI.AccountController
Diffstat (limited to 'lib/pleroma/web/controller_helper.ex')
-rw-r--r--lib/pleroma/web/controller_helper.ex7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/pleroma/web/controller_helper.ex b/lib/pleroma/web/controller_helper.ex
index e90bf842e..83b884ba9 100644
--- a/lib/pleroma/web/controller_helper.ex
+++ b/lib/pleroma/web/controller_helper.ex
@@ -68,4 +68,11 @@ defmodule Pleroma.Web.ControllerHelper do
conn
end
end
+
+ def assign_account_by_id(%{params: %{"id" => id}} = conn, _) do
+ case Pleroma.User.get_cached_by_id(id) do
+ %Pleroma.User{} = account -> assign(conn, :account, account)
+ nil -> Pleroma.Web.MastodonAPI.FallbackController.call(conn, {:error, :not_found}) |> halt()
+ end
+ end
end