diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2019-07-17 16:22:57 +0000 |
---|---|---|
committer | Ariadne Conill <ariadne@dereferenced.org> | 2019-07-17 16:33:08 +0000 |
commit | a9d6a12bb3e71bafc11fe7cf5e44ad5bc9981cf9 (patch) | |
tree | 12a37dbe3b7842fbe873bd61e775104ca38e4064 | |
parent | 4885473be2704d4d370fdb96e1473bc4eb9368f4 (diff) | |
download | pleroma-a9d6a12bb3e71bafc11fe7cf5e44ad5bc9981cf9.tar.gz |
activitypub: controller: rework the way the relay actor is presented so the code can be reused
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub_controller.ex | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index e2af4ad1a..dc9ef066d 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -206,9 +206,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do json(conn, dgettext("errors", "error")) end - def relay(conn, _params) do - with %User{} = user <- Relay.get_actor(), - {:ok, user} <- User.ensure_keys_present(user) do + defp represent_service_actor(%User{} = user, conn) do + with {:ok, user} <- User.ensure_keys_present(user) do conn |> put_resp_header("content-type", "application/activity+json") |> json(UserView.render("user.json", %{user: user})) @@ -217,6 +216,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do 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 conn |> put_resp_header("content-type", "application/activity+json") |