+
+ def assign_account_by_id(conn, _) do
+ case Pleroma.User.get_cached_by_id(conn.params.id) do
+ %Pleroma.User{} = account ->
+ assign(conn, :account, account)
+
+ nil ->
+ Pleroma.Web.MastodonAPI.FallbackController.call(conn, {:error, :not_found})
+ |> halt()
+ end
+ end
+
+ @spec try_render(Plug.Conn.t(), any, any) :: Plug.Conn.t()
+ def try_render(conn, target, params) when is_binary(target) do
+ render(conn, target, params)
+ end
+
+ def try_render(conn, _, _) do
+ render_error(conn, :not_implemented, "Can't display this activity")
+ end
+
+ @doc """
+ Returns true if request specifies to include embedded relationships in account objects.
+ May only be used in selected account-related endpoints; has no effect for status- or
+ notification-related endpoints.
+ """
+ # Intended for PleromaFE: https://git.pleroma.social/pleroma/pleroma-fe/-/issues/838
+ def embed_relationships?(params) do
+ # To do once OpenAPI transition mess is over: just `truthy_param?(params[:with_relationships])`
+ params
+ |> Map.get(:with_relationships, params["with_relationships"])
+ |> Params.truthy_param?()
+ end