ActivityPubControllerTest: Apply same addr changes to object
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 15 Sep 2020 16:18:57 +0000 (18:18 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Mon, 5 Apr 2021 17:19:12 +0000 (19:19 +0200)
lib/pleroma/web/activity_pub/utils.ex
test/pleroma/web/activity_pub/activity_pub_controller_test.exs

index a4dc469dccc38c3b04ef805707eb3e6d7b2d2617..e81623d833817cd5bb9c8c5bc2cd9ece92b401f1 100644 (file)
@@ -97,7 +97,10 @@ defmodule Pleroma.Web.ActivityPub.Utils do
 
     if need_splice? do
       cc_list = extract_list(params["cc"])
-      Map.put(params, "cc", [ap_id | cc_list])
+
+      params
+      |> Map.put("cc", [ap_id | cc_list])
+      |> Kernel.put_in(["object", "cc"], [ap_id | cc_list])
     else
       params
     end
index 2de52323ebe06417506fb96a4f681e760f7e9ae1..f6ea9e2caf609d1a25de28b8b304cf97bfbd1788 100644 (file)
@@ -649,7 +649,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
 
     test "it inserts an incoming activity into the database", %{conn: conn, data: data} do
       user = insert(:user)
-      data = Map.put(data, "bcc", [user.ap_id])
+
+      data =
+        data
+        |> Map.put("bcc", [user.ap_id])
+        |> Kernel.put_in(["object", "bcc"], [user.ap_id])
 
       conn =
         conn
@@ -666,8 +670,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       user = insert(:user)
 
       data =
-        Map.put(data, "to", user.ap_id)
-        |> Map.delete("cc")
+        data
+        |> Map.put("to", user.ap_id)
+        |> Map.put("cc", [])
+        |> Kernel.put_in(["object", "to"], user.ap_id)
+        |> Kernel.put_in(["object", "cc"], [])
 
       conn =
         conn
@@ -684,8 +691,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       user = insert(:user)
 
       data =
-        Map.put(data, "cc", user.ap_id)
-        |> Map.delete("to")
+        data
+        |> Map.put("to", [])
+        |> Map.put("cc", user.ap_id)
+        |> Kernel.put_in(["object", "to"], [])
+        |> Kernel.put_in(["object", "cc"], user.ap_id)
 
       conn =
         conn
@@ -703,9 +713,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
       user = insert(:user)
 
       data =
-        Map.put(data, "bcc", user.ap_id)
-        |> Map.delete("to")
-        |> Map.delete("cc")
+        data
+        |> Map.put("to", [])
+        |> Map.put("cc", [])
+        |> Map.put("bcc", user.ap_id)
+        |> Kernel.put_in(["object", "to"], [])
+        |> Kernel.put_in(["object", "cc"], [])
+        |> Kernel.put_in(["object", "bcc"], user.ap_id)
 
       conn =
         conn