Handle subscriptions in queue.
authorRoger Braun <roger@rogerbraun.net>
Wed, 2 Aug 2017 10:34:48 +0000 (12:34 +0200)
committerRoger Braun <roger@rogerbraun.net>
Wed, 2 Aug 2017 10:34:48 +0000 (12:34 +0200)
lib/pleroma/web/federator/federator.ex
lib/pleroma/web/websub/websub.ex

index 8d4f497b831efe0da5348652459f855995f9429e..4d6ebff8e42434f7c48b7542fe803fd48bcab6c5 100644 (file)
@@ -26,6 +26,15 @@ defmodule Pleroma.Web.Federator do
     end)
   end
 
+  def handle(:request_subscription, websub) do
+    Logger.debug("Refreshing #{websub.topic}")
+    with {:ok, websub } <- Websub.request_subscription(websub) do
+      Logger.debug("Successfully refreshed #{websub.topic}")
+    else
+      _e -> Logger.debug("Couldn't refresh #{websub.topic}")
+    end
+  end
+
   def handle(:publish, activity) do
     Logger.debug(fn -> "Running publish for #{activity.data["id"]}" end)
     with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do
index 932bf186267dcea50d773139dedd5d4a3e6aa4c2..17fc42cb53065460f429b79211881c73026adc99 100644 (file)
@@ -216,8 +216,8 @@ defmodule Pleroma.Web.Websub do
 
     subs = Repo.all(query)
 
-    Enum.map(subs, fn (sub) ->
-      request_subscription(sub)
+    Enum.each(subs, fn (sub) ->
+      Pleroma.Web.Federator.enqueue(:request_subscription, sub)
     end)
   end
 end