diff options
Diffstat (limited to 'test/web/rich_media')
-rw-r--r-- | test/web/rich_media/helpers_test.exs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/web/rich_media/helpers_test.exs b/test/web/rich_media/helpers_test.exs index 48884319d..e74890fd5 100644 --- a/test/web/rich_media/helpers_test.exs +++ b/test/web/rich_media/helpers_test.exs @@ -118,4 +118,24 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do assert %{} = Helpers.fetch_data_for_activity(activity4) assert %{} = Helpers.fetch_data_for_activity(activity5) end + + test "only crawls from local posts when [:rich_media, :enabled] is set to :local_only" do + content = ~s[<a href="https://example.com/ogp">https://example.com/ogp</a>] + remote_user = insert(:user, local: false) + local_user = insert(:user, local: true) + remote_note = insert(:note, %{user: remote_user, data: %{"content" => content}}) + local_note = insert(:note, %{user: local_user, data: %{"content" => content}}) + + remote_activity = + insert(:note_activity, %{user: remote_user, note: remote_note, local: false}) + + local_activity = insert(:note_activity, %{user: local_user, note: local_note, local: true}) + + Config.put([:rich_media, :enabled], :local_only) + + assert %{} == Helpers.fetch_data_for_activity(remote_activity) + + assert %{page_url: "https://example.com/ogp", rich_media: _} = + Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(local_activity) + end end |