diff options
author | lambda <pleromagit@rogerbraun.net> | 2019-02-14 19:54:16 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2019-02-14 19:54:16 +0000 |
commit | ea2698beb75074e6c94acf0c66bcdbdb47f59acd (patch) | |
tree | afe67efdcc38753cbad4b324e811fb2630afe31d /test | |
parent | 1d17082ab2523eb75ee0ca4a49e45da0d0edabd7 (diff) | |
parent | 889ad95a2a766b82d17aa148d92754ecda244bf7 (diff) | |
download | pleroma-ea2698beb75074e6c94acf0c66bcdbdb47f59acd.tar.gz |
Merge branch 'bugfix/activitypub-reserialization' into 'develop'
activitypub transmogrifier: fix reserialization edge cases
See merge request pleroma/pleroma!826
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index e5e3c8d33..86c66deff 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -1128,4 +1128,58 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do ) end end + + describe "reserialization" do + test "successfully reserializes a message with inReplyTo == nil" do + user = insert(:user) + + message = %{ + "@context" => "https://www.w3.org/ns/activitystreams", + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [], + "type" => "Create", + "object" => %{ + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [], + "type" => "Note", + "content" => "Hi", + "inReplyTo" => nil, + "attributedTo" => user.ap_id + }, + "actor" => user.ap_id + } + + {:ok, activity} = Transmogrifier.handle_incoming(message) + + {:ok, _} = Transmogrifier.prepare_outgoing(activity.data) + end + + test "successfully reserializes a message with AS2 objects in IR" do + user = insert(:user) + + message = %{ + "@context" => "https://www.w3.org/ns/activitystreams", + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [], + "type" => "Create", + "object" => %{ + "to" => ["https://www.w3.org/ns/activitystreams#Public"], + "cc" => [], + "type" => "Note", + "content" => "Hi", + "inReplyTo" => nil, + "attributedTo" => user.ap_id, + "tag" => [ + %{"name" => "#2hu", "href" => "http://example.com/2hu", "type" => "Hashtag"}, + %{"name" => "Bob", "href" => "http://example.com/bob", "type" => "Mention"} + ] + }, + "actor" => user.ap_id + } + + {:ok, activity} = Transmogrifier.handle_incoming(message) + + {:ok, _} = Transmogrifier.prepare_outgoing(activity.data) + end + end end |