alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Federator.Publisher
alias Pleroma.Web.OStatus
- alias Pleroma.Web.Websub
alias Pleroma.Workers.PublisherWorker
alias Pleroma.Workers.ReceiverWorker
- alias Pleroma.Workers.SubscriberWorker
require Logger
- def init do
- # To do: consider removing this call in favor of scheduled execution (`quantum`-based)
- refresh_subscriptions(schedule_in: 60)
- end
-
@doc "Addresses [memory leaks on recursive replies fetching](https://git.pleroma.social/pleroma/pleroma/issues/161)"
# credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
def allowed_incoming_reply_depth?(depth) do
PublisherWorker.enqueue("publish", %{"activity_id" => activity.id})
end
- def verify_websub(websub) do
- SubscriberWorker.enqueue("verify_websub", %{"websub_id" => websub.id})
- end
-
- def request_subscription(websub) do
- SubscriberWorker.enqueue("request_subscription", %{"websub_id" => websub.id})
- end
-
- def refresh_subscriptions(worker_args \\ []) do
- SubscriberWorker.enqueue("refresh_subscriptions", %{}, worker_args ++ [max_attempts: 1])
- end
-
# Job Worker Callbacks
@spec perform(atom(), module(), any()) :: {:ok, any()} | {:error, any()}
end
end
- def perform(: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 perform(:verify_websub, websub) do
- Logger.debug(fn ->
- "Running WebSub verification for #{websub.id} (#{websub.topic}, #{websub.callback})"
- end)
-
- Websub.verify(websub)
- end
-
- def perform(:refresh_subscriptions) do
- Logger.debug("Federator running refresh subscriptions")
- Websub.refresh_subscriptions()
- end
-
def ap_enabled_actor(id) do
user = User.get_cached_by_ap_id(id)
+++ /dev/null
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Workers.SubscriberWorker do
- alias Pleroma.Repo
- alias Pleroma.Web.Federator
- alias Pleroma.Web.Websub
-
- use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
-
- @impl Oban.Worker
- def perform(%{"op" => "refresh_subscriptions"}, _job) do
- Federator.perform(:refresh_subscriptions)
- end
-
- def perform(%{"op" => "request_subscription", "websub_id" => websub_id}, _job) do
- websub = Repo.get(Websub.WebsubClientSubscription, websub_id)
- Federator.perform(:request_subscription, websub)
- end
-
- def perform(%{"op" => "verify_websub", "websub_id" => websub_id}, _job) do
- websub = Repo.get(Websub.WebsubServerSubscription, websub_id)
- Federator.perform(:verify_websub, websub)
- end
-end