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
This commit is contained in:
commit
1e0fa899b6
|
@ -339,7 +339,7 @@ def fix_content_map(object), do: object
|
||||||
def fix_type(%{"inReplyTo" => reply_id} = object) when is_binary(reply_id) do
|
def fix_type(%{"inReplyTo" => reply_id} = object) when is_binary(reply_id) do
|
||||||
reply = Object.normalize(reply_id)
|
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")
|
Map.put(object, "type", "Answer")
|
||||||
else
|
else
|
||||||
object
|
object
|
||||||
|
|
|
@ -60,6 +60,22 @@ test "it fetches replied-to activities if we don't have them" do
|
||||||
assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
assert returned_object.data["inReplyToAtomUri"] == "https://shitposter.club/notice/2827873"
|
||||||
end
|
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
|
test "it works for incoming notices" do
|
||||||
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue