From 871e9e84926c93acffa72a710907b98ef88192fb Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Thu, 19 Jun 2025 12:36:31 +0300 Subject: [PATCH] Make unaddressed_message? condsider [] as empty --- changelog.d/fix-report-empty-fields.fix | 1 + lib/pleroma/web/activity_pub/utils.ex | 6 +++++- .../web/activity_pub/activity_pub_controller_test.exs | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelog.d/fix-report-empty-fields.fix diff --git a/changelog.d/fix-report-empty-fields.fix b/changelog.d/fix-report-empty-fields.fix new file mode 100644 index 000000000..ba0a2b2a2 --- /dev/null +++ b/changelog.d/fix-report-empty-fields.fix @@ -0,0 +1 @@ +Fix reports being rejected when the activity had an empty CC or TO field (instead of not having them at all) \ No newline at end of file diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 807ec8710..c5a6901d4 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -82,7 +82,11 @@ defmodule Pleroma.Web.ActivityPub.Utils do def unaddressed_message?(params), do: [params["to"], params["cc"], params["bto"], params["bcc"]] - |> Enum.all?(&is_nil(&1)) + |> Enum.all?(fn + nil -> true + [] -> true + _ -> false + end) @spec recipient_in_message(User.t(), User.t(), map()) :: boolean() def recipient_in_message(%User{ap_id: ap_id} = recipient, %User{} = actor, params), diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs index 46b3d5f0d..0c35f4aab 100644 --- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs +++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs @@ -1205,9 +1205,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do } ], "actor" => actor.ap_id, - "cc" => [ - reported_user.ap_id - ], + # CC and TO might either not exist at all, or be empty. We should be able to handle either. + # "cc" => [], "content" => "test", "context" => "context", "id" => "http://#{remote_domain}/activities/02be56cf-35e3-46b4-b2c6-47ae08dfee9e",