Make unaddressed_message? condsider [] as empty

This commit is contained in:
Ekaterina Vaartis 2025-06-19 12:36:31 +03:00
commit 871e9e8492
3 changed files with 8 additions and 4 deletions

View file

@ -0,0 +1 @@
Fix reports being rejected when the activity had an empty CC or TO field (instead of not having them at all)

View file

@ -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),

View file

@ -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",