Browse Source

EnsureRePrepended: Don't break on chat messages.

chore/update-floki-find-usage
lain 3 years ago
parent
commit
edf8b6abfe
2 changed files with 12 additions and 1 deletions
  1. +2
    -1
      lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex
  2. +10
    -0
      test/web/activity_pub/mrf/ensure_re_prepended_test.exs

+ 2
- 1
lib/pleroma/web/activity_pub/mrf/ensure_re_prepended.ex View File

@@ -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"])


+ 10
- 0
test/web/activity_pub/mrf/ensure_re_prepended_test.exs View File

@@ -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

Loading…
Cancel
Save