federator: remove websub stuff
This commit is contained in:
parent
25b7ff56c3
commit
b16a460916
|
@ -11,18 +11,11 @@ defmodule Pleroma.Web.Federator do
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.Federator.Publisher
|
alias Pleroma.Web.Federator.Publisher
|
||||||
alias Pleroma.Web.OStatus
|
alias Pleroma.Web.OStatus
|
||||||
alias Pleroma.Web.Websub
|
|
||||||
alias Pleroma.Workers.PublisherWorker
|
alias Pleroma.Workers.PublisherWorker
|
||||||
alias Pleroma.Workers.ReceiverWorker
|
alias Pleroma.Workers.ReceiverWorker
|
||||||
alias Pleroma.Workers.SubscriberWorker
|
|
||||||
|
|
||||||
require Logger
|
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)"
|
@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
|
# credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
|
||||||
def allowed_incoming_reply_depth?(depth) do
|
def allowed_incoming_reply_depth?(depth) do
|
||||||
|
@ -53,18 +46,6 @@ def publish(activity) do
|
||||||
PublisherWorker.enqueue("publish", %{"activity_id" => activity.id})
|
PublisherWorker.enqueue("publish", %{"activity_id" => activity.id})
|
||||||
end
|
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
|
# Job Worker Callbacks
|
||||||
|
|
||||||
@spec perform(atom(), module(), any()) :: {:ok, any()} | {:error, any()}
|
@spec perform(atom(), module(), any()) :: {:ok, any()} | {:error, any()}
|
||||||
|
@ -111,29 +92,6 @@ def perform(:incoming_ap_doc, params) do
|
||||||
end
|
end
|
||||||
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
|
def ap_enabled_actor(id) do
|
||||||
user = User.get_cached_by_ap_id(id)
|
user = User.get_cached_by_ap_id(id)
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
# 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
|
|
Loading…
Reference in New Issue