commit: 269b61a2402e3d12d09baf26ba73359776f556b0
parent: de5c7e20a36ecb0f08e8c1d8248cdb288003cacf
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date: Wed, 29 Jul 2020 12:20:04 +0000
Merge branch '1996-dont-break-on-chatmessages' into 'develop'
EnsureRePrepended: Don't break on chat messages.
Closes #1996
See merge request pleroma/pleroma!2808
Diffstat:
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex b/lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex
@@ -27,7 +27,8 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
def filter_by_summary(_in_reply_to, child), do: child
- def filter(%{"type" => "Create", "object" => child_object} = object) do
+ def filter(%{"type" => "Create", "object" => child_object} = object)
+ when is_map(child_object) do
child =
child_object["inReplyTo"]
|> Object.normalize(child_object["inReplyTo"])
diff --git a/test/web/activity_pub/mrf/ensure_re_prepended_test.exs b/test/web/activity_pub/mrf/ensure_re_prepended_test.exs
@@ -78,5 +78,15 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
assert {:ok, res} = EnsureRePrepended.filter(message)
assert res == message
end
+
+ test "it skips if the object is only a reference" do
+ message = %{
+ "type" => "Create",
+ "object" => "somereference"
+ }
+
+ assert {:ok, res} = EnsureRePrepended.filter(message)
+ assert res == message
+ end
end
end