From 6d8df8c1a261fcadef4fd6ef2541c3c2b30a6074 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 3 Dec 2024 21:17:12 +0100 Subject: [PATCH] fixes and an attempt at making backfetching work for existing users --- lib/pleroma/web/activity_pub/activity_pub.ex | 9 +++++---- lib/pleroma/workers/remote_fetcher_worker.ex | 6 +----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index bfd14ebbd..c3bd69ae5 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1874,15 +1874,15 @@ def enqueue_outbox_fetches( # enqueue a task to fetch the outbox Logger.debug("Refetching outbox #{outbox_address}") - User.outbox_refreshed(user) - Pleroma.Workers.RemoteFetcherWorker.enqueue("fetch_outbox", %{ "id" => outbox_address }) + User.outbox_refreshed(user) + :ok else - Logger.debug("Not refetching outbox (TTL not reached)") + Logger.debug("Not refetching outbox (TTL not reached: #{last_fetch}, age #{NaiveDateTime.diff(NaiveDateTime.utc_now(), last_fetch)})") end :ok @@ -1891,7 +1891,8 @@ def enqueue_outbox_fetches( def enqueue_outbox_fetches(%{local: true}), do: :ok def enqueue_outbox_fetches(%{local: false} = user) do - # TODO: get outbox? + make_user_from_ap_id(user.ap_id) + :ok end def make_user_from_ap_id(ap_id, additional \\ []) do diff --git a/lib/pleroma/workers/remote_fetcher_worker.ex b/lib/pleroma/workers/remote_fetcher_worker.ex index ad68c79c8..9574dbf3e 100644 --- a/lib/pleroma/workers/remote_fetcher_worker.ex +++ b/lib/pleroma/workers/remote_fetcher_worker.ex @@ -17,11 +17,7 @@ def perform(%Job{args: %{"op" => "fetch_outbox", "id" => address}}) do with {:ok, outbox} <- ActivityPub.fetch_and_prepare_collection_from_ap_id(address) do Enum.each(Enum.reverse(outbox), fn {ap_id, _} -> if is_nil(Object.get_cached_by_ap_id(ap_id)) do - perform(%{ - "op" => "fetch_remote", - "id" => ap_id, - "depth" => 1 - }) + Fetcher.fetch_object_from_id(ap_id, depth: 1) end end)