From b135fa35a1e6258dbe1a07438213ce2593d86bc2 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 24 Jun 2024 09:46:55 -0400 Subject: [PATCH] RichMedia: test that activity is streamed out --- changelog.d/rich_media_stream_test.skip | 0 config/test.exs | 3 ++- lib/pleroma/web/rich_media/backfill.ex | 6 +++++- test/pleroma/web/rich_media/card_test.exs | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog.d/rich_media_stream_test.skip diff --git a/changelog.d/rich_media_stream_test.skip b/changelog.d/rich_media_stream_test.skip new file mode 100644 index 000000000..e69de29bb diff --git a/config/test.exs b/config/test.exs index 1e8168548..410b9bbab 100644 --- a/config/test.exs +++ b/config/test.exs @@ -184,7 +184,8 @@ config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000 config :pleroma, Pleroma.Emoji.Loader, test_emoji: true -config :pleroma, Pleroma.Web.RichMedia.Backfill, provider: Pleroma.Web.RichMedia.Backfill +config :pleroma, Pleroma.Web.RichMedia.Backfill, + stream_out: Pleroma.Web.ActivityPub.ActivityPubMock if File.exists?("./config/test.secret.exs") do import_config "test.secret.exs" diff --git a/lib/pleroma/web/rich_media/backfill.ex b/lib/pleroma/web/rich_media/backfill.ex index 1d8cc87d4..f1ee83bf0 100644 --- a/lib/pleroma/web/rich_media/backfill.ex +++ b/lib/pleroma/web/rich_media/backfill.ex @@ -11,6 +11,10 @@ defmodule Pleroma.Web.RichMedia.Backfill do require Logger @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + @stream_out_impl Pleroma.Config.get( + [__MODULE__, :stream_out], + Pleroma.Web.ActivityPub.ActivityPub + ) @spec run(map()) :: :ok | {:error, {:invalid_metadata, any()} | :body_too_large | {:content, any()} | any()} @@ -64,7 +68,7 @@ defmodule Pleroma.Web.RichMedia.Backfill do defp stream_update(%{"activity_id" => activity_id}) do Pleroma.Activity.get_by_id(activity_id) |> Pleroma.Activity.normalize() - |> Pleroma.Web.ActivityPub.ActivityPub.stream_out() + |> @stream_out_impl.stream_out() end defp warm_cache(key, val), do: @cachex.put(:rich_media_cache, key, val) diff --git a/test/pleroma/web/rich_media/card_test.exs b/test/pleroma/web/rich_media/card_test.exs index 33d07127f..9541627c1 100644 --- a/test/pleroma/web/rich_media/card_test.exs +++ b/test/pleroma/web/rich_media/card_test.exs @@ -39,6 +39,9 @@ defmodule Pleroma.Web.RichMedia.CardTest do content_type: "text/markdown" }) + Pleroma.Web.ActivityPub.ActivityPubMock + |> expect(:stream_out, fn ^activity -> nil end) + assert_enqueued( worker: RichMediaWorker, args: %{"url" => url, "activity_id" => activity.id}