diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/share-gs.xml | 99 | ||||
-rw-r--r-- | test/fixtures/share.xml | 54 | ||||
-rw-r--r-- | test/web/ostatus/ostatus_test.exs | 26 |
3 files changed, 179 insertions, 0 deletions
diff --git a/test/fixtures/share-gs.xml b/test/fixtures/share-gs.xml new file mode 100644 index 000000000..ab5e488bd --- /dev/null +++ b/test/fixtures/share-gs.xml @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/"> + <generator uri="https://gnu.io/social" version="1.0.2-dev">GNU social</generator> + <id>https://social.heldscal.la/api/statuses/user_timeline/23211.atom</id> + <title>lambadalambda timeline</title> + <subtitle>Updates from lambadalambda on social.heldscal.la!</subtitle> + <logo>https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg</logo> + <updated>2017-05-03T08:05:41+00:00</updated> +<author> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://social.heldscal.la/user/23211</uri> + <name>lambadalambda</name> + <summary>Call me Deacon Blues.</summary> + <link rel="alternate" type="text/html" href="https://social.heldscal.la/lambadalambda"/> + <link rel="avatar" type="image/jpeg" media:width="236" media:height="236" href="https://social.heldscal.la/avatar/23211-original-20170416114255.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="96" media:height="96" href="https://social.heldscal.la/avatar/23211-96-20170416114255.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="48" media:height="48" href="https://social.heldscal.la/avatar/23211-48-20170416114255.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="24" media:height="24" href="https://social.heldscal.la/avatar/23211-24-20170416114257.jpeg"/> + <poco:preferredUsername>lambadalambda</poco:preferredUsername> + <poco:displayName>Constance Variable</poco:displayName> + <poco:note>Call me Deacon Blues.</poco:note> + <poco:address> + <poco:formatted>Berlin</poco:formatted> + </poco:address> + <poco:urls> + <poco:type>homepage</poco:type> + <poco:value>https://heldscal.la</poco:value> + <poco:primary>true</poco:primary> + </poco:urls> + <followers url="https://social.heldscal.la/lambadalambda/subscribers"></followers> + <statusnet:profile_info local_id="23211"></statusnet:profile_info> +</author> + <link href="https://social.heldscal.la/lambadalambda" rel="alternate" type="text/html"/> + <link href="https://social.heldscal.la/main/sup" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/> + <link href="https://social.heldscal.la/main/push/hub" rel="hub"/> + <link href="https://social.heldscal.la/main/salmon/user/23211" rel="salmon"/> + <link href="https://social.heldscal.la/main/salmon/user/23211" rel="http://salmon-protocol.org/ns/salmon-replies"/> + <link href="https://social.heldscal.la/main/salmon/user/23211" rel="http://salmon-protocol.org/ns/salmon-mention"/> + <link href="https://social.heldscal.la/api/statuses/user_timeline/23211.atom" rel="self" type="application/atom+xml"/> +<entry> + <id>tag:social.heldscal.la,2017-05-03:noticeId=2028428:objectType=note</id> + <title>lambadalambda repeated a notice by lain</title> + <content type="html">RT @<a href="https://pleroma.soykaf.com/users/lain" class="h-card u-url p-nickname mention" title="Lain Iwakura">lain</a> Added returning the entries as xml... let's see if the mastodon hammering stops now.</content> + <link rel="alternate" type="text/html" href="https://social.heldscal.la/notice/2028428"/> + <activity:verb>http://activitystrea.ms/schema/1.0/share</activity:verb> + <published>2017-05-03T08:05:41+00:00</published> + <updated>2017-05-03T08:05:41+00:00</updated> + <activity:object> + <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type> + <id>https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193</id> + <title></title> + <content type="html">Added returning the entries as xml... let's see if the mastodon hammering stops now.</content> + <link rel="alternate" type="text/html" href="https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193"/> + <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> + <published>2017-05-03T08:04:44+00:00</published> + <updated>2017-05-03T08:04:44+00:00</updated> + <author> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://pleroma.soykaf.com/users/lain</uri> + <name>lain</name> + <summary>Test account</summary> + <link rel="alternate" type="text/html" href="https://pleroma.soykaf.com/users/lain"/> + <link rel="avatar" type="image/jpeg" media:width="250" media:height="202" href="https://social.heldscal.la/avatar/43188-original-20170429171039.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="96" media:height="96" href="https://social.heldscal.la/avatar/43188-96-20170429172422.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="48" media:height="48" href="https://social.heldscal.la/avatar/43188-48-20170429172422.jpeg"/> + <link rel="avatar" type="image/jpeg" media:width="24" media:height="24" href="https://social.heldscal.la/avatar/43188-24-20170429181411.jpeg"/> + <poco:preferredUsername>lain</poco:preferredUsername> + <poco:displayName>Lain Iwakura</poco:displayName> + <poco:note>Test account</poco:note> + <statusnet:profile_info local_id="43188"></statusnet:profile_info> + </author> + <activity:object> + <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> + <id>https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193</id> + <title>New note by lain</title> + <content type="html">Added returning the entries as xml... let's see if the mastodon hammering stops now.</content> + <link rel="alternate" type="text/html" href="https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193"/> + <status_net notice_id="2028424"></status_net> + </activity:object> + <link rel="ostatus:conversation" href="https://social.heldscal.la/conversation/1042737"/> + <ostatus:conversation href="https://social.heldscal.la/conversation/1042737" local_id="1042737" ref="https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22">https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22</ostatus:conversation> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <source> + <id>https://pleroma.soykaf.com/users/lain/feed.atom</id> + <title>Lain Iwakura</title> + <link rel="alternate" type="text/html" href="https://pleroma.soykaf.com/users/lain"/> + <link rel="self" type="application/atom+xml" href="https://pleroma.soykaf.com/users/lain/feed.atom"/> + <icon>https://social.heldscal.la/avatar/43188-96-20170429172422.jpeg</icon> + <updated>2017-05-03T08:04:44+00:00</updated> + </source> + </activity:object> + <link rel="ostatus:conversation" href="https://social.heldscal.la/conversation/1042737"/> + <ostatus:conversation href="https://social.heldscal.la/conversation/1042737" local_id="1042737" ref="https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22">https://pleroma.soykaf.com/contexts/ede39a2b-7cf3-4fa4-8ccd-cb97431bcc22</ostatus:conversation> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <link rel="self" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/show/2028428.atom"/> + <link rel="edit" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/show/2028428.atom"/> + <statusnet:notice_info local_id="2028428" source="api" repeat_of="2028424"></statusnet:notice_info> +</entry> +</feed> diff --git a/test/fixtures/share.xml b/test/fixtures/share.xml new file mode 100644 index 000000000..e07b88680 --- /dev/null +++ b/test/fixtures/share.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:mastodon="http://mastodon.social/schema/1.0"> + <id>tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status</id> + <published>2017-05-03T08:21:09Z</published> + <updated>2017-05-03T08:21:09Z</updated> + <title>lambadalambda shared a status by lain@pleroma.soykaf.com</title> + <author> + <id>https://mastodon.social/users/lambadalambda</id> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://mastodon.social/users/lambadalambda</uri> + <name>lambadalambda</name> + <email>lambadalambda@mastodon.social</email> + <link rel="alternate" type="text/html" href="https://mastodon.social/@lambadalambda"/> + <link rel="avatar" type="image/gif" media:width="120" media:height="120" href="https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif"/> + <link rel="header" type="" media:width="700" media:height="335" href="/headers/original/missing.png"/> + <poco:preferredUsername>lambadalambda</poco:preferredUsername> + <poco:displayName>Critical Value</poco:displayName> + <mastodon:scope>public</mastodon:scope> + </author> + <activity:object-type>http://activitystrea.ms/schema/1.0/activity</activity:object-type> + <activity:verb>http://activitystrea.ms/schema/1.0/share</activity:verb> + <activity:object> + <id>https://pleroma.soykaf.com/objects/4c1bda26-902e-4525-9fcd-b9fd44925193</id> + <published>2017-05-03T08:04:44Z</published> + <updated>2017-05-03T08:05:52Z</updated> + <title>New status by lain@pleroma.soykaf.com</title> + <author> + <id>https://pleroma.soykaf.com/users/lain</id> + <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> + <uri>https://pleroma.soykaf.com/users/lain</uri> + <name>lain</name> + <email>lain@pleroma.soykaf.com</email> + <summary type="html">Test account</summary> + <link rel="alternate" type="text/html" href="https://pleroma.soykaf.com/users/lain"/> + <link rel="avatar" type="image/jpeg" media:width="120" media:height="120" href="https://files.mastodon.social/accounts/avatars/000/125/902/original/6B3AFC74ACA841B24CFB94DB9044C84EDE6AFF31C71718B023D413DAED09A68E.jpeg"/> + <link rel="header" type="" media:width="700" media:height="335" href="/headers/original/missing.png"/> + <poco:preferredUsername>lain</poco:preferredUsername> + <poco:displayName>Lain Iwakura</poco:displayName> + <poco:note>Test account</poco:note> + <mastodon:scope>public</mastodon:scope> + </author> + <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> + <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> + <content type="html" xml:lang="en">Added returning the entries as xml... let's see if the mastodon hammering stops now.</content> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <mastodon:scope>public</mastodon:scope> + <link rel="alternate" type="text/html" href=""/> + </activity:object> + <content type="html" xml:lang="en">Added returning the entries as xml... let's see if the mastodon hammering stops now.</content> + <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/> + <mastodon:scope>public</mastodon:scope> + <link rel="alternate" type="text/html" href="https://mastodon.social/users/lambadalambda/updates/2232660"/> + <link rel="self" type="application/atom+xml" href="https://mastodon.social/users/lambadalambda/updates/2232660.atom"/> +</entry> diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs index 94a735337..e85d7677c 100644 --- a/test/web/ostatus/ostatus_test.exs +++ b/test/web/ostatus/ostatus_test.exs @@ -70,6 +70,32 @@ defmodule Pleroma.Web.OStatusTest do assert activity.data["object"]["inReplyTo"] == "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note" end + test "handle incoming retweets - GS, subscription" do + incoming = File.read!("test/fixtures/share-gs.xml") + {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Announce" + assert activity.data["actor"] == "https://social.heldscal.la/user/23211" + assert activity.data["object"] == retweeted_activity.data["object"]["id"] + refute activity.local + assert retweeted_activity.data["type"] == "Create" + assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain" + refute retweeted_activity.local + end + + test "handle incoming retweets - Mastodon, salmon" do + incoming = File.read!("test/fixtures/share.xml") + {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming) + + assert activity.data["type"] == "Announce" + assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda" + assert activity.data["object"] == retweeted_activity.data["object"]["id"] + refute activity.local + assert retweeted_activity.data["type"] == "Create" + assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain" + refute retweeted_activity.local + end + test "handle incoming replies" do incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml") {:ok, [activity]} = OStatus.handle_incoming(incoming) |