aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>2020-11-27 00:25:24 +0100
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>2021-04-05 19:19:12 +0200
commit53193b84b1d07c9fd3c6b80c04e3eada4fb4cd59 (patch)
treea65ed713199143cff7a97d524e66c8195cd99594
parent0b88accae632e371becacb16be4e8798aa80c705 (diff)
downloadpleroma-53193b84b1d07c9fd3c6b80c04e3eada4fb4cd59.tar.gz
utils: Fix maybe_splice_recipient when "object" isn’t a map
-rw-r--r--lib/pleroma/maps.ex6
-rw-r--r--lib/pleroma/web/activity_pub/utils.ex6
-rw-r--r--test/pleroma/web/activity_pub/activity_pub_controller_test.exs1
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/pleroma/maps.ex b/lib/pleroma/maps.ex
index 0d2e94248..b08b83305 100644
--- a/lib/pleroma/maps.ex
+++ b/lib/pleroma/maps.ex
@@ -12,4 +12,10 @@ defmodule Pleroma.Maps do
_ -> map
end
end
+
+ def safe_put_in(data, keys, value) when is_map(data) and is_list(keys) do
+ Kernel.put_in(data, keys, value)
+ rescue
+ _ -> data
+ end
end
diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex
index e81623d83..0d1a6d0f1 100644
--- a/lib/pleroma/web/activity_pub/utils.ex
+++ b/lib/pleroma/web/activity_pub/utils.ex
@@ -96,11 +96,11 @@ defmodule Pleroma.Web.ActivityPub.Utils do
!label_in_collection?(ap_id, params["cc"])
if need_splice? do
- cc_list = extract_list(params["cc"])
+ cc = [ap_id | extract_list(params["cc"])]
params
- |> Map.put("cc", [ap_id | cc_list])
- |> Kernel.put_in(["object", "cc"], [ap_id | cc_list])
+ |> Map.put("cc", cc)
+ |> Maps.safe_put_in(["object", "cc"], cc)
else
params
end
diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
index f6ea9e2ca..f3ce703e2 100644
--- a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
@@ -1003,7 +1003,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
"actor" => remote_actor,
"content" => "test report",
"id" => "https://#{remote_domain}/e3b12fd1-948c-446e-b93b-a5e67edbe1d8",
- "nickname" => reported_user.nickname,
"object" => [
reported_user.ap_id,
note.data["object"]