activitypub: controller: rework the way the relay actor is presented so the code can be reused
This commit is contained in:
parent
4885473be2
commit
a9d6a12bb3
|
@ -206,9 +206,8 @@ def inbox(conn, params) do
|
||||||
json(conn, dgettext("errors", "error"))
|
json(conn, dgettext("errors", "error"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def relay(conn, _params) do
|
defp represent_service_actor(%User{} = user, conn) do
|
||||||
with %User{} = user <- Relay.get_actor(),
|
with {:ok, user} <- User.ensure_keys_present(user) do
|
||||||
{:ok, user} <- User.ensure_keys_present(user) do
|
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "application/activity+json")
|
|> put_resp_header("content-type", "application/activity+json")
|
||||||
|> json(UserView.render("user.json", %{user: user}))
|
|> json(UserView.render("user.json", %{user: user}))
|
||||||
|
@ -217,6 +216,13 @@ def relay(conn, _params) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp represent_service_actor(nil, _), do: {:error, :not_found}
|
||||||
|
|
||||||
|
def relay(conn, _params) do
|
||||||
|
Relay.get_actor()
|
||||||
|
|> represent_service_actor(conn)
|
||||||
|
end
|
||||||
|
|
||||||
def whoami(%{assigns: %{user: %User{} = user}} = conn, _params) do
|
def whoami(%{assigns: %{user: %User{} = user}} = conn, _params) do
|
||||||
conn
|
conn
|
||||||
|> put_resp_header("content-type", "application/activity+json")
|
|> put_resp_header("content-type", "application/activity+json")
|
||||||
|
|
Loading…
Reference in New Issue