activitypub: refactor relay concerns into new relay module
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 06:15:22 +0000 (06:15 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:22:10 +0000 (08:22 +0000)
lib/pleroma/web/activity_pub/activity_pub_controller.ex
lib/pleroma/web/activity_pub/relay.ex [new file with mode: 0644]

index a858b5df900323aa7816e33e5eddc1ebf4026039..52b2a467ebb50a87a992c1e99ce7eced66dc3328 100644 (file)
@@ -3,6 +3,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
   alias Pleroma.{User, Object}
   alias Pleroma.Web.ActivityPub.{ObjectView, UserView}
   alias Pleroma.Web.ActivityPub.ActivityPub
+  alias Pleroma.Web.ActivityPub.Relay
   alias Pleroma.Web.Federator
 
   require Logger
@@ -108,7 +109,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
   end
 
   def relay(conn, params) do
-    with %User{} = user <- User.get_or_create_instance_user(),
+    with %User{} = user <- Relay.get_actor(),
          {:ok, user} <- Pleroma.Web.WebFinger.ensure_keys_present(user) do
       conn
       |> put_resp_header("content-type", "application/activity+json")
diff --git a/lib/pleroma/web/activity_pub/relay.ex b/lib/pleroma/web/activity_pub/relay.ex
new file mode 100644 (file)
index 0000000..736d0e4
--- /dev/null
@@ -0,0 +1,7 @@
+defmodule Pleroma.Web.ActivityPub.Relay do
+  alias Pleroma.User
+
+  def get_actor do
+    User.get_or_create_instance_user()
+  end
+end