diff options
Diffstat (limited to 'lib/pleroma/web/controller_helper.ex')
-rw-r--r-- | lib/pleroma/web/controller_helper.ex | 7 |
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 |