1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.Subscriber do
7 alias Pleroma.Web.Websub
8 alias Pleroma.Web.Websub.WebsubClientSubscription
12 # Note: `max_attempts` is intended to be overridden in `new/1` call
14 queue: "federator_outgoing",
15 max_attempts: Pleroma.Config.get([:workers, :retries, :compile_time_default])
18 def perform(%{"op" => "refresh_subscriptions"}) do
19 Websub.refresh_subscriptions()
20 # Schedule the next run in 6 hours
21 Pleroma.Web.Federator.refresh_subscriptions(schedule_in: 3600 * 6)
24 def perform(%{"op" => "request_subscription", "websub_id" => websub_id}) do
25 websub = Repo.get(WebsubClientSubscription, websub_id)
26 Logger.debug("Refreshing #{websub.topic}")
28 with {:ok, websub} <- Websub.request_subscription(websub) do
29 Logger.debug("Successfully refreshed #{websub.topic}")
31 _e -> Logger.debug("Couldn't refresh #{websub.topic}")
35 def perform(%{"op" => "verify_websub", "websub_id" => websub_id}) do
36 websub = Repo.get(WebsubClientSubscription, websub_id)
39 "Running WebSub verification for #{websub.id} (#{websub.topic}, #{websub.callback})"