activitypub: introduce internal fetch service actor
authorAriadne Conill <ariadne@dereferenced.org>
Wed, 17 Jul 2019 17:14:08 +0000 (17:14 +0000)
committerAriadne Conill <ariadne@dereferenced.org>
Wed, 17 Jul 2019 17:14:08 +0000 (17:14 +0000)
lib/pleroma/application.ex
lib/pleroma/web/activity_pub/internal_fetch_actor.ex [new file with mode: 0644]

index ba4cf8486c9f0d773b3440641a81428b242e7be8..0353314914ba82c35d062adde2cf6db7caeedf46 100644 (file)
@@ -140,6 +140,11 @@ defmodule Pleroma.Application do
             id: :federator_init,
             start: {Task, :start_link, [&Pleroma.Web.Federator.init/0]},
             restart: :temporary
+          },
+          %{
+            id: :internal_fetch_init,
+            start: {Task, :start_link, [&Pleroma.Web.ActivityPub.InternalFetchActor.init/0]},
+            restart: :temporary
           }
         ] ++
         streamer_child() ++
diff --git a/lib/pleroma/web/activity_pub/internal_fetch_actor.ex b/lib/pleroma/web/activity_pub/internal_fetch_actor.ex
new file mode 100644 (file)
index 0000000..9213ddd
--- /dev/null
@@ -0,0 +1,20 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ActivityPub.InternalFetchActor do
+  alias Pleroma.User
+
+  require Logger
+
+  def init do
+    # Wait for everything to settle.
+    Process.sleep(1000 * 5)
+    get_actor()
+  end
+
+  def get_actor do
+    "#{Pleroma.Web.Endpoint.url()}/internal/fetch"
+    |> User.get_or_create_service_actor_by_ap_id("internal.fetch")
+  end
+end