commit: 4496dc81c4e6bccf88eb4f0397e8a7c65a8cf17a
parent 6ed9d681b902f6d5be3c2e37f5bc2704501bb5f5
Author: Lain Soykaf <lain@lain.com>
Date: Sun, 21 Dec 2025 15:19:05 +0400
TransmogrifierTest, CreateGenericValidatorTest: Add regression tests for addressing.
Diffstat:
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs b/test/pleroma/web/activity_pub/object_validators/create_generic_validator_test.exs
@@ -59,4 +59,37 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidatorTest do
assert validated.valid?
assert {:context, note["context"]} in validated.changes
end
+
+ test "a Create/Note without addressing falls back to the Note's recipients" do
+ user = insert(:user)
+
+ note = %{
+ "id" => Utils.generate_object_id(),
+ "type" => "Note",
+ "actor" => user.ap_id,
+ "to" => [user.follower_address],
+ "cc" => [],
+ "content" => "Hello world",
+ "context" => Utils.generate_context_id()
+ }
+
+ note_activity = %{
+ "id" => Utils.generate_activity_id(),
+ "type" => "Create",
+ "actor" => note["actor"],
+ "object" => note,
+ "published" => DateTime.utc_now() |> DateTime.to_iso8601(),
+ "context" => Utils.generate_context_id()
+ }
+
+ # Build metadata
+ {:ok, object_data} = ObjectValidator.cast_and_apply(note_activity["object"])
+ meta = [object_data: ObjectValidator.stringify_keys(object_data)]
+
+ validated = CreateGenericValidator.cast_and_validate(note_activity, meta)
+
+ assert validated.valid?
+ assert Ecto.Changeset.get_field(validated, :to) == note["to"]
+ assert Ecto.Changeset.get_field(validated, :cc) == note["cc"]
+ end
end
diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs
@@ -143,6 +143,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert {:ok, activity} = Transmogrifier.handle_incoming(message)
object = Object.normalize(activity, fetch: false)
+ assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
assert "https://www.w3.org/ns/activitystreams#Public" in object.data["to"]
end