From 0abe01be2e2c9c7b9e9ee46555508f5d8bbc16c2 Mon Sep 17 00:00:00 2001 From: Oneric Date: Mon, 17 Mar 2025 23:02:13 +0100 Subject: [PATCH] federation/in: always copy object addressing into its Create activity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we later only consider the Create activity for access permission checks, but the semantically more sensible set of fields are the object’s. Changing the check itself to use the object may have unintended consequences on already existing legacy posts as the old code which processed it when it arrived may have never considered effects on the objects addressing fields. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 4469f3d49..55985d310 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -211,13 +211,12 @@ def fix_in_reply_to(object, _options), do: object # Pleroma sends unlisted posts without addressing public scope in the enclosing activity # but we only use the ativity for access perm cheks, see: # https://git.pleroma.social/pleroma/pleroma/-/issues/3323 - defp fix_create_visibility(%{"type" => "Create", "object" => %{"cc" => occ}} = activity) do - acc = activity["cc"] - if Pleroma.Constants.as_public() in occ and not (Pleroma.Constants.as_public() in acc) do - Map.put(activity, "cc", [Pleroma.Constants.as_public() | acc]) - else - activity - end + defp fix_create_visibility(%{"type" => "Create", "object" => %{} = object} = activity) do + activity + |> Map.put("to", object["to"]) + |> Map.put("cc", object["cc"]) + |> Map.put("bto", object["bto"]) + |> Map.put("bcc", object["bcc"]) end defp fix_create_visibility(activity), do: activity