diff options
author | lain <lain@soykaf.club> | 2019-06-08 10:22:15 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2019-06-08 10:22:15 +0000 |
commit | 1e0fa899b65622d9668599ed0f4ff0fdbe2d44e8 (patch) | |
tree | 93ab9005c8e47cbe6046ae53f4248cf5de8fc763 | |
parent | d7f4f65560cab7c07969c910ffdf742b159cbb22 (diff) | |
parent | dffc9f060adf43a4faaa5790dc8a01b3d7cb5e34 (diff) | |
download | pleroma-1e0fa899b65622d9668599ed0f4ff0fdbe2d44e8.tar.gz pleroma-1e0fa899b65622d9668599ed0f4ff0fdbe2d44e8.zip |
Merge branch 'fix/transmogrifier-inReplyTo' into 'develop'
Transmogrifier: Do not crash if inReplyTo does not exist and can't be fetched
See merge request pleroma/pleroma!1259
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 2 | ||||
-rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index ff031a16e..3bb8b40b5 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -339,7 +339,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def fix_type(%{"inReplyTo" => reply_id} = object) when is_binary(reply_id) do reply = Object.normalize(reply_id) - if reply.data["type"] == "Question" and object["name"] do + if reply && (reply.data["type"] == "Question" and object["name"]) do Map.put(object, "type", "Answer") else object diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 28971ae45..cc1781403 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -60,6 +60,22 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873" end + test "it does not crash if the object in inReplyTo can't be fetched" do + data = + File.read!("test/fixtures/mastodon-post-activity.json") + |> Poison.decode!() + + object = + data["object"] + |> Map.put("inReplyTo", "https://404.site/whatever") + + data = + data + |> Map.put("object", object) + + {:ok, _returned_activity} = Transmogrifier.handle_incoming(data) + end + test "it works for incoming notices" do data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() |