Handle subscriptions in queue.

This commit is contained in:
Roger Braun 2017-08-02 12:34:48 +02:00
parent 54af9e145a
commit e4a4135c1d
2 changed files with 11 additions and 2 deletions

View File

@ -26,6 +26,15 @@ defmodule Pleroma.Web.Federator do
end) end)
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 def handle(:publish, activity) do
Logger.debug(fn -> "Running publish for #{activity.data["id"]}" end) 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 with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do

View File

@ -216,8 +216,8 @@ defmodule Pleroma.Web.Websub do
subs = Repo.all(query) subs = Repo.all(query)
Enum.map(subs, fn (sub) -> Enum.each(subs, fn (sub) ->
request_subscription(sub) Pleroma.Web.Federator.enqueue(:request_subscription, sub)
end) end)
end end
end end