From e4a4135c1d3f7d5783e78934f8b4198cc2435dbe Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 2 Aug 2017 12:34:48 +0200 Subject: [PATCH] Handle subscriptions in queue. --- lib/pleroma/web/federator/federator.ex | 9 +++++++++ lib/pleroma/web/websub/websub.ex | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index 8d4f497b8..4d6ebff8e 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -26,6 +26,15 @@ def handle(:refresh_subscriptions, _) 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 diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex index 932bf1862..17fc42cb5 100644 --- a/lib/pleroma/web/websub/websub.ex +++ b/lib/pleroma/web/websub/websub.ex @@ -216,8 +216,8 @@ def refresh_subscriptions(delta \\ 60 * 60 * 24) 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