From 27ec46814cfb5515b16727d36bb028b5634b6b5d Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 12 Jun 2025 21:27:19 -0700 Subject: [PATCH] Revert "Public getting stripped from unlisted activity CC: Add possible tests" This reverts commit ded40182b0aa6848b55febe73ec7e41eace1e0f6. --- test/fixtures/poast_unlisted.json | 65 ------------------- .../transmogrifier/note_handling_test.exs | 31 --------- .../web/activity_pub/transmogrifier_test.exs | 37 ----------- 3 files changed, 133 deletions(-) delete mode 100644 test/fixtures/poast_unlisted.json diff --git a/test/fixtures/poast_unlisted.json b/test/fixtures/poast_unlisted.json deleted file mode 100644 index fa23153ba..000000000 --- a/test/fixtures/poast_unlisted.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "@context" : [ - "https://www.w3.org/ns/activitystreams", - "https://poa.st/schemas/litepub-0.1.jsonld", - { - "@language" : "und" - } - ], - "actor" : "https://poa.st/users/TrevorGoodchild", - "attachment" : [], - "attributedTo" : "https://poa.st/users/TrevorGoodchild", - "cc" : [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "context" : "https://poa.st/contexts/c6d125f1-4e7f-43bd-aa31-33de4d90d049", - "conversation" : "https://poa.st/contexts/c6d125f1-4e7f-43bd-aa31-33de4d90d049", - "directMessage" : false, - "id" : "https://poa.st/activities/bbd3347a-4a89-4cdb-bf86-4f9eed9506e3", - "object" : { - "actor" : "https://poa.st/users/TrevorGoodchild", - "attachment" : [], - "attributedTo" : "https://poa.st/users/TrevorGoodchild", - "cc" : [ - "https://www.w3.org/ns/activitystreams#Public" - ], - "content" : "@HoroTheWhiteWolf >please let this be his zero fucks given final statement before he joins the 52%+ tranny club", - "context" : "https://poa.st/contexts/c6d125f1-4e7f-43bd-aa31-33de4d90d049", - "conversation" : "https://poa.st/contexts/c6d125f1-4e7f-43bd-aa31-33de4d90d049", - "id" : "https://poa.st/objects/7eb785d5-a556-4070-9091-f4afb226466c", - "inReplyTo" : "https://poa.st/objects/71995b41-cfb2-48ce-abce-76d570d54edc", - "published" : "2025-05-03T23:54:07.489885Z", - "repliesCount" : 2, - "sensitive" : false, - "source" : { - "content" : ">please let this be his zero fucks given final statement before he joins the 52%+ tranny club", - "mediaType" : "text/plain" - }, - "summary" : "", - "tag" : [ - { - "href" : "https://poa.st/users/HoroTheWhiteWolf", - "name" : "@HoroTheWhiteWolf", - "type" : "Mention" - } - ], - "to" : [ - "https://poa.st/users/HoroTheWhiteWolf", - "https://poa.st/users/TrevorGoodchild/followers" - ], - "type" : "Note" - }, - "published" : "2025-05-03T23:54:07.489837Z", - "tag" : [ - { - "href" : "https://poa.st/users/HoroTheWhiteWolf", - "name" : "@HoroTheWhiteWolf", - "type" : "Mention" - } - ], - "to" : [ - "https://poa.st/users/HoroTheWhiteWolf", - "https://poa.st/users/TrevorGoodchild/followers" - ], - "type" : "Create" -} diff --git a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs index 13982940a..fd7a3c772 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/note_handling_test.exs @@ -786,35 +786,4 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do assert object.data["context"] == object.data["inReplyTo"] assert modified.data["context"] == object.data["inReplyTo"] end - - test "it keeps the public address in cc in the activity when it is present" do - data = - File.read!("test/fixtures/mastodon-post-activity.json") - |> Jason.decode!() - - object = - data["object"] - |> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"]) - |> Map.put("to", []) - - data = - data - |> Map.put("object", object) - |> Map.put("cc", ["https://www.w3.org/ns/activitystreams#Public"]) - |> Map.put("to", []) - - {:ok, %Activity{} = modified} = Transmogrifier.handle_incoming(data) - assert modified.data["cc"] == ["https://www.w3.org/ns/activitystreams#Public"] - end - - test "it tries it with the real poast_unlisted.json, ensuring that public is in the cc" do - data = - File.read!("test/fixtures/poast_unlisted.json") - |> Jason.decode!() - - _user = insert(:user, ap_id: data["actor"]) - - {:ok, %Activity{} = modified} = Transmogrifier.handle_incoming(data) - assert modified.data["cc"] == ["https://www.w3.org/ns/activitystreams#Public"] - end end diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs index ef6e004f1..e0395d7bb 100644 --- a/test/pleroma/web/activity_pub/transmogrifier_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs @@ -757,43 +757,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do refute recipient.follower_address in fixed_object["cc"] refute recipient.follower_address in fixed_object["to"] end - - test "preserves public URL in cc even when not explicitly mentioned", %{user: user} do - public_url = "https://www.w3.org/ns/activitystreams#Public" - - # Case 1: Public URL in cc but no mentions - object = %{ - "actor" => user.ap_id, - "to" => ["https://social.beepboop.ga/users/dirb"], - "cc" => [public_url], - "tag" => [] - } - - fixed_object = Transmogrifier.fix_explicit_addressing(object, user.follower_address) - assert public_url in fixed_object["cc"] - - # Case 2: Public URL in cc, with mentions but public not in to - object = %{ - "actor" => user.ap_id, - "to" => ["https://pleroma.gold/users/user1"], - "cc" => [public_url], - "tag" => [%{"type" => "Mention", "href" => "https://pleroma.gold/users/user1"}] - } - - fixed_object = Transmogrifier.fix_explicit_addressing(object, user.follower_address) - assert public_url in fixed_object["cc"] - - # Case 3: Public URL in to, it should be moved to to - object = %{ - "actor" => user.ap_id, - "to" => [public_url], - "cc" => [], - "tag" => [] - } - - fixed_object = Transmogrifier.fix_explicit_addressing(object, user.follower_address) - assert public_url in fixed_object["to"] - end end describe "fix_summary/1" do