From aa79d64e0d278e30cb05cc3145a9539ea684bc6f Mon Sep 17 00:00:00 2001 From: lain Date: Fri, 23 Feb 2018 15:00:41 +0100 Subject: [PATCH] Correctly stitch mastodon -> ostatus replies. --- .../web/activity_pub/transmogrifier.ex | 19 +- test/fixtures/httpoison_mock/7369654.atom | 44 ++ test/fixtures/httpoison_mock/7369654.html | 665 ++++++++++++++++++ test/fixtures/httpoison_mock/mayumayu.json | 1 + .../fixtures/httpoison_mock/mayumayupost.json | 1 + test/fixtures/httpoison_mock/spc_5381.atom | 438 ++++++++++++ test/fixtures/httpoison_mock/spc_5381_xrd.xml | 20 + test/support/httpoison_mock.ex | 42 ++ test/web/activity_pub/activity_pub_test.exs | 8 + test/web/activity_pub/transmogrifier_test.exs | 5 - 10 files changed, 1235 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/httpoison_mock/7369654.atom create mode 100644 test/fixtures/httpoison_mock/7369654.html create mode 100644 test/fixtures/httpoison_mock/mayumayu.json create mode 100644 test/fixtures/httpoison_mock/mayumayupost.json create mode 100644 test/fixtures/httpoison_mock/spc_5381.atom create mode 100644 test/fixtures/httpoison_mock/spc_5381_xrd.xml diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index a845d64b5..a3bbae2a5 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -10,6 +10,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do import Ecto.Query + require Logger + @doc """ Modifies an incoming AP object (mastodon format) to our internal format. """ @@ -43,6 +45,20 @@ def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Note"} = obje with nil <- Activity.get_create_activity_by_object_ap_id(object["id"]), %User{} = user <- User.get_or_fetch_by_ap_id(data["actor"]) do object = fix_object(data["object"]) + + replied_to_id = if object["inReplyTo"] do + case ActivityPub.fetch_object_from_id(object["inReplyTo"]) do + {:ok, object} -> object.data["id"] + e -> + Logger.error("Couldn't fetch #{object["inReplyTo"]} #{inspect(e)}") + nil + end + else + nil + end + + object = Map.put(object, "inReplyTo", replied_to_id || object["inReplyTo"]) + params = %{ to: data["to"], object: object, @@ -56,9 +72,6 @@ def handle_incoming(%{"type" => "Create", "object" => %{"type" => "Note"} = obje ]) } - if object["inReplyTo"] do - {:ok, object} = ActivityPub.fetch_object_from_id(object["inReplyTo"]) - end ActivityPub.create(params) else diff --git a/test/fixtures/httpoison_mock/7369654.atom b/test/fixtures/httpoison_mock/7369654.atom new file mode 100644 index 000000000..74fd9ce6b --- /dev/null +++ b/test/fixtures/httpoison_mock/7369654.atom @@ -0,0 +1,44 @@ + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-22:noticeId=7369654:objectType=comment + New comment by shpuld + @<a href="https://testing.pleroma.lol/users/lain" class="h-card mention" title="Rael Electric Razor">lain</a> me far right + + + http://activitystrea.ms/schema/1.0/post + 2018-02-22T09:20:12+00:00 + 2018-02-22T09:20:12+00:00 + + http://activitystrea.ms/schema/1.0/person + https://shitposter.club/user/5381 + shpuld + + + + + + shpuld + shp + + + + + + + tag:shitposter.club,2018-02-22:objectType=thread:nonce=e5a7c72d60a9c0e4 + + + + https://shitposter.club/api/statuses/user_timeline/5381.atom + shp + + + + https://shitposter.club/avatar/5381-96-20171230093854.png + 2018-02-23T13:30:15+00:00 + + + + + diff --git a/test/fixtures/httpoison_mock/7369654.html b/test/fixtures/httpoison_mock/7369654.html new file mode 100644 index 000000000..a75a90b90 --- /dev/null +++ b/test/fixtures/httpoison_mock/7369654.html @@ -0,0 +1,665 @@ + + + + Shitposter Club + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
Please enable javascript to use this site.
+
+

WARNING: this site filled with KREMLIN TROLLS

_
+
+
+
+
+ +
+ + + + +
+ · + + OpenID
+
+
+ +
+
+
+
+

+ +

+
+
+
+
+ +
+
+
    + + +
  1. + +
    + shp (shpuld)'s status on Thursday, 22-Feb-2018 09:20:12 UTC + + shp +shp + +
    + + +
    +
  2. +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + diff --git a/test/fixtures/httpoison_mock/mayumayu.json b/test/fixtures/httpoison_mock/mayumayu.json new file mode 100644 index 000000000..2d5cdae1e --- /dev/null +++ b/test/fixtures/httpoison_mock/mayumayu.json @@ -0,0 +1 @@ +{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":"as:movedTo","Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji"}],"id":"https://mstdn.io/users/mayuutann","type":"Person","following":"https://mstdn.io/users/mayuutann/following","followers":"https://mstdn.io/users/mayuutann/followers","inbox":"https://mstdn.io/users/mayuutann/inbox","outbox":"https://mstdn.io/users/mayuutann/outbox","preferredUsername":"mayuutann","name":"Mayutan☕","summary":"\u003cp\u003eI enjoy programming as a hobby.\u003cbr /\u003eJava.Ruby. Practicing English . I love karaoke.\u003cbr /\u003eAichi Japan.\u003cbr /\u003eI\u0026apos;d be glad if you pointed out it when my English is unnatural.\u003c/p\u003e","url":"https://mstdn.io/@mayuutann","manuallyApprovesFollowers":false,"publicKey":{"id":"https://mstdn.io/users/mayuutann#main-key","owner":"https://mstdn.io/users/mayuutann","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvz+MncrdPxQ5R99g9m8X\nY6QO1WNOsCj0wXuDmCHJxXfJx5NFYgsYSX3y2UTzoHNcxZIwbSy24HlYR44cEygy\nimiysTk3o0pVquXhFQNDBXJkAkPfY+9O/gz1FTbwEUzFS1m9zmoQUesDjHEBXvpW\nHkNRdVThsDHotiMYjd+WYS09XjCYxhUHcwsnEFZ+55y1Uz6OveY2OZH+jTEluF+s\nLLTDopY37Ogniah0zVm7Q+/WPdbjOullpWh8s/c5fYGl5xMaS950l5r4gkPU7MVE\n4dGSd/v4pUAxlZrhbRHrKMD4c9cmxn9gJuqmW49ZmPzIeG+SaLnad6zh0BN9nveR\njQIDAQAB\n-----END PUBLIC KEY-----\n"},"endpoints":{"sharedInbox":"https://mstdn.io/inbox"},"icon":{"type":"Image","mediaType":"image/jpeg","url":"https://mstdn.io/system/accounts/avatars/000/021/478/original/40fe303d51305ba4.jpg"},"image":{"type":"Image","mediaType":"image/jpeg","url":"https://mstdn.io/system/accounts/headers/000/021/478/original/4e1e9b5e1f350abb.jpg"}} \ No newline at end of file diff --git a/test/fixtures/httpoison_mock/mayumayupost.json b/test/fixtures/httpoison_mock/mayumayupost.json new file mode 100644 index 000000000..fbee043e6 --- /dev/null +++ b/test/fixtures/httpoison_mock/mayumayupost.json @@ -0,0 +1 @@ +{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":"as:movedTo","Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji"}],"id":"https://mstdn.io/users/mayuutann/statuses/99568293732299394","type":"Note","summary":null,"content":"\u003cp\u003e\u003cspan class=\"h-card\"\u003e\u003ca href=\"https://shitposter.club/shpuld\" class=\"u-url mention\"\u003e@\u003cspan\u003eshpuld\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e \u003cspan class=\"h-card\"\u003e\u003ca href=\"https://testing.pleroma.lol/users/lain\" class=\"u-url mention\"\u003e@\u003cspan\u003elain\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e ポポポォォォ\u003c/p\u003e","inReplyTo":"https://shitposter.club/notice/7369654","published":"2018-02-22T09:26:31Z","url":"https://mstdn.io/@mayuutann/99568293732299394","attributedTo":"https://mstdn.io/users/mayuutann","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mstdn.io/users/mayuutann/followers","https://testing.pleroma.lol/users/lain","https://shitposter.club/user/5381"],"sensitive":false,"atomUri":"https://mstdn.io/users/mayuutann/statuses/99568293732299394","inReplyToAtomUri":"tag:shitposter.club,2018-02-22:noticeId=7369654:objectType=comment","conversation":"tag:shitposter.club,2018-02-22:objectType=thread:nonce=e5a7c72d60a9c0e4","attachment":[],"tag":[{"type":"Mention","href":"https://testing.pleroma.lol/users/lain","name":"@lain@testing.pleroma.lol"},{"type":"Mention","href":"https://shitposter.club/user/5381","name":"@shpuld@shitposter.club"}]} \ No newline at end of file diff --git a/test/fixtures/httpoison_mock/spc_5381.atom b/test/fixtures/httpoison_mock/spc_5381.atom new file mode 100644 index 000000000..c3288e97b --- /dev/null +++ b/test/fixtures/httpoison_mock/spc_5381.atom @@ -0,0 +1,438 @@ + + + GNU social + https://shitposter.club/api/statuses/user_timeline/5381.atom + shpuld timeline + Updates from shpuld on Shitposter Club! + https://shitposter.club/avatar/5381-96-20171230093854.png + 2018-02-23T13:42:22+00:00 + + http://activitystrea.ms/schema/1.0/person + https://shitposter.club/user/5381 + shpuld + + + + + + shpuld + shp + + + + + + + + + + + + + tag:shitposter.club,2018-02-23:fave:5381:comment:7387801:2018-02-23T13:39:40+00:00 + Favorite + shpuld favorited something by mayuutann: <p><span class="h-card"><a href="https://freezepeach.xyz/hakui" class="u-url mention">@<span>hakui</span></a></span> <span class="h-card"><a href="https://gs.smuglo.li/histoire" class="u-url mention">@<span>histoire</span></a></span> <span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> <a href="https://mstdn.io/media/_Ee-x91XN0udpfZVO_U" rel="nofollow"><span class="invisible">https://</span><span class="ellipsis">mstdn.io/media/_Ee-x91XN0udpfZ</span><span class="invisible">VO_U</span></a></p> + + http://activitystrea.ms/schema/1.0/favorite + 2018-02-23T13:39:40+00:00 + 2018-02-23T13:39:40+00:00 + + http://activitystrea.ms/schema/1.0/comment + https://mstdn.io/users/mayuutann/statuses/99574950785668071 + New comment by mayuutann + <p><span class="h-card"><a href="https://freezepeach.xyz/hakui" class="u-url mention">@<span>hakui</span></a></span> <span class="h-card"><a href="https://gs.smuglo.li/histoire" class="u-url mention">@<span>histoire</span></a></span> <span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> <a href="https://mstdn.io/media/_Ee-x91XN0udpfZVO_U" rel="nofollow"><span class="invisible">https://</span><span class="ellipsis">mstdn.io/media/_Ee-x91XN0udpfZ</span><span class="invisible">VO_U</span></a></p> + + + + + + + https://freezepeach.xyz/conversation/4182511 + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387723:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> @<a href="https://pleroma.soykaf.com/users/lain" class="h-card mention" title="&#x2468; lain &#x2468;">lain</a> how naive~ + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:30:15+00:00 + 2018-02-23T13:30:15+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=2f09acf104aebfe3 + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387703:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> @<a href="https://pleroma.soykaf.com/users/lain" class="h-card mention" title="&#x2468; lain &#x2468;">lain</a> you expect anyone to believe that?? + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:28:08+00:00 + 2018-02-23T13:28:08+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=2f09acf104aebfe3 + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387639:objectType=comment + New comment by shpuld + @<a href="https://mstdn.io/users/mayuutann" class="h-card mention" title="Mayutan&#x2615;">mayuutann</a> @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> pacyuri!! <a href="https://shitposter.club/file/eea140be45df3f993c4533026bf9a78fe8facd296d2fa0c6d02b2e347c5dc30e.jpg" title="https://shitposter.club/file/eea140be45df3f993c4533026bf9a78fe8facd296d2fa0c6d02b2e347c5dc30e.jpg" class="attachment" id="attachment-1589462" rel="nofollow external">https://shitposter.club/attachment/1589462</a> + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:20:38+00:00 + 2018-02-23T13:20:38+00:00 + + + + https://freezepeach.xyz/conversation/4183220 + + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387611:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> why is pacyu eating a pizza so cute + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:18:07+00:00 + 2018-02-23T13:18:07+00:00 + + + + https://freezepeach.xyz/conversation/4183220 + + + + + + + + tag:shitposter.club,2018-02-23:fave:5381:comment:7387600:2018-02-23T13:17:52+00:00 + Favorite + shpuld favorited something by mayuutann: <p><span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> <span class="h-card"><a href="https://gs.smuglo.li/histoire" class="u-url mention">@<span>histoire</span></a></span> <span class="h-card"><a href="https://freezepeach.xyz/hakui" class="u-url mention">@<span>hakui</span></a></span> pichu! <a href="https://mstdn.io/media/Crv5eubz1KO0dgBEulI" rel="nofollow"><span class="invisible">https://</span><span class="ellipsis">mstdn.io/media/Crv5eubz1KO0dgB</span><span class="invisible">EulI</span></a></p> + + http://activitystrea.ms/schema/1.0/favorite + 2018-02-23T13:17:52+00:00 + 2018-02-23T13:17:52+00:00 + + http://activitystrea.ms/schema/1.0/comment + https://mstdn.io/users/mayuutann/statuses/99574863865459283 + New comment by mayuutann + <p><span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> <span class="h-card"><a href="https://gs.smuglo.li/histoire" class="u-url mention">@<span>histoire</span></a></span> <span class="h-card"><a href="https://freezepeach.xyz/hakui" class="u-url mention">@<span>hakui</span></a></span> pichu! <a href="https://mstdn.io/media/Crv5eubz1KO0dgBEulI" rel="nofollow"><span class="invisible">https://</span><span class="ellipsis">mstdn.io/media/Crv5eubz1KO0dgB</span><span class="invisible">EulI</span></a></p> + + + + + + + https://freezepeach.xyz/conversation/4182511 + + + + + + + tag:shitposter.club,2018-02-23:fave:5381:comment:7387544:2018-02-23T13:12:43+00:00 + Favorite + shpuld favorited something by mayuutann: <p><span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> wa~~i!! :blobcheer:</p> + + http://activitystrea.ms/schema/1.0/favorite + 2018-02-23T13:12:43+00:00 + 2018-02-23T13:12:43+00:00 + + http://activitystrea.ms/schema/1.0/comment + https://mstdn.io/users/mayuutann/statuses/99574840290947233 + New comment by mayuutann + <p><span class="h-card"><a href="https://shitposter.club/shpuld" class="u-url mention">@<span>shpuld</span></a></span> wa~~i!! :blobcheer:</p> + + + + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=d05e2b056274c5ab + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387555:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> more!! + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:12:23+00:00 + 2018-02-23T13:12:23+00:00 + + + + https://freezepeach.xyz/conversation/4183220 + + + + + + + + tag:shitposter.club,2018-02-23:fave:5381:note:7387537:2018-02-23T13:12:19+00:00 + Favorite + shpuld favorited something by hakui: you have pacyupacyu'd for: 45 minutes 03 seconds + + http://activitystrea.ms/schema/1.0/favorite + 2018-02-23T13:12:19+00:00 + 2018-02-23T13:12:19+00:00 + + http://activitystrea.ms/schema/1.0/note + tag:freezepeach.xyz,2018-02-23:noticeId=6451332:objectType=note + New note by hakui + you have pacyupacyu'd for: 45 minutes 03 seconds + + + + + + + https://freezepeach.xyz/conversation/4183220 + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387539:objectType=comment + New comment by shpuld + @<a href="https://mstdn.io/users/mayuutann" class="h-card mention" title="Mayutan&#x2615;">mayuutann</a> ndndnd~ + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:11:04+00:00 + 2018-02-23T13:11:04+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=d05e2b056274c5ab + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387518:objectType=comment + New comment by shpuld + @<a href="https://mstdn.io/users/mayuutann" class="h-card mention" title="Mayutan&#x2615;">mayuutann</a> well done! mayumayu is so energetic + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:08:50+00:00 + 2018-02-23T13:08:50+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=d05e2b056274c5ab + + + + + + + + tag:shitposter.club,2018-02-23:fave:5381:note:7387503:2018-02-23T13:08:00+00:00 + Favorite + shpuld favorited something by mayuutann: <p>done with FIGURE MAT!!<br /> (Posted with IFTTT)</p> + + http://activitystrea.ms/schema/1.0/favorite + 2018-02-23T13:08:00+00:00 + 2018-02-23T13:08:00+00:00 + + http://activitystrea.ms/schema/1.0/note + https://mstdn.io/users/mayuutann/statuses/99574825526201897 + New note by mayuutann + <p>done with FIGURE MAT!!<br /> (Posted with IFTTT)</p> + + + + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=c6aaa9b91e8d242f + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387486:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> @<a href="https://a.weirder.earth/users/mutstd" class="h-card mention" title="Mutant Standard">mutstd</a> @<a href="https://donphan.social/users/Siphonay" class="h-card mention" title="Siphonay">siphonay</a> jokes on you I'm oppressively shitposting myself + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:05:44+00:00 + 2018-02-23T13:05:44+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=5d306467336c9661 + + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387466:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> @<a href="https://a.weirder.earth/users/mutstd" class="h-card mention" title="Mutant Standard">mutstd</a> @<a href="https://donphan.social/users/Siphonay" class="h-card mention" title="Siphonay">siphonay</a> how does it feel being hostile + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:04:10+00:00 + 2018-02-23T13:04:10+00:00 + + + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=5d306467336c9661 + + + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387459:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> gorogoro + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:03:32+00:00 + 2018-02-23T13:03:32+00:00 + + + + https://freezepeach.xyz/conversation/4181784 + + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387432:objectType=comment + New comment by shpuld + @<a href="https://freezepeach.xyz/user/3458" class="h-card mention" title="&#x5FA1;&#x5712;&#x306F;&#x304F;&#x3044;">hakui</a> ndnd + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T13:02:05+00:00 + 2018-02-23T13:02:05+00:00 + + + + https://freezepeach.xyz/conversation/4181784 + + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:shitposter.club,2018-02-23:noticeId=7387367:objectType=note + New note by shpuld + dear diary: I'm trying to do work but I can only think of tenshi eating a corndog + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T12:56:03+00:00 + 2018-02-23T12:56:03+00:00 + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=57f316da416743fc + + + + + + + http://activitystrea.ms/schema/1.0/note + tag:shitposter.club,2018-02-23:noticeId=7387354:objectType=note + New note by shpuld + jesus christ it's such a fridey at work + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T12:53:50+00:00 + 2018-02-23T12:53:50+00:00 + + tag:shitposter.club,2018-02-23:objectType=thread:nonce=c05eb5e91bdcbdb7 + + + + + + + http://activitystrea.ms/schema/1.0/comment + tag:shitposter.club,2018-02-23:noticeId=7387343:objectType=comment + New comment by shpuld + @<a href="https://gs.smuglo.li/user/589" class="h-card mention" title="&#x16DE;&#x16A9;&#x16B3;&#x16C1;&#x16DE;&#x16A9;&#x16B3;&#x16C1;">dokidoki</a> give them free upgrades to krokodil + + + http://activitystrea.ms/schema/1.0/post + 2018-02-23T12:53:15+00:00 + 2018-02-23T12:53:15+00:00 + + + + https://gs.smuglo.li/conversation/3934774 + + + + + + + diff --git a/test/fixtures/httpoison_mock/spc_5381_xrd.xml b/test/fixtures/httpoison_mock/spc_5381_xrd.xml new file mode 100644 index 000000000..b15fb276d --- /dev/null +++ b/test/fixtures/httpoison_mock/spc_5381_xrd.xml @@ -0,0 +1,20 @@ + + + https://shitposter.club/user/5381 + acct:shpuld@shitposter.club + https://shitposter.club/shpuld + https://shitposter.club/index.php/user/5381 + https://shitposter.club/index.php/shpuld + + + + + + + + + + + + + diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex index b8f2422f6..ad9be9aef 100644 --- a/test/support/httpoison_mock.ex +++ b/test/support/httpoison_mock.ex @@ -80,6 +80,13 @@ def get("https://shitposter.club/.well-known/webfinger?resource=https://shitpost }} end + def get("https://shitposter.club/.well-known/webfinger?resource=https://shitposter.club/user/5381", [Accept: "application/xrd+xml"], []) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/spc_5381_xrd.xml") + }} + end + def get("http://gs.example.org/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "http://gs.example.org:4040/index.php/user/1"], follow_redirect: true]) do {:ok, %Response{ status_code: 200, @@ -122,6 +129,13 @@ def get("https://social.heldscal.la/api/statuses/user_timeline/29191.atom", _bod }} end + def get("https://shitposter.club/api/statuses/user_timeline/5381.atom", _body, _headers) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/spc_5381.atom") + }} + end + def get("https://social.heldscal.la/api/statuses/user_timeline/23211.atom", _body, _headers) do {:ok, %Response{ status_code: 200, @@ -387,6 +401,13 @@ def get("https://niu.moe/users/rye", ["Accept": "application/activity+json"], _) }} end + def get("https://mstdn.io/users/mayuutann", ["Accept": "application/activity+json"], _) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/mayumayu.json") + }} + end + def get("http://mastodon.example.org/@admin/99541947525187367", ["Accept": "application/activity+json"], _) do {:ok, %Response{ status_code: 200, @@ -394,6 +415,27 @@ def get("http://mastodon.example.org/@admin/99541947525187367", ["Accept": "appl }} end + def get("https://mstdn.io/users/mayuutann/statuses/99568293732299394", ["Accept": "application/activity+json"], _) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/mayumayupost.json") + }} + end + + def get("https://shitposter.club/notice/7369654", _, _) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/7369654.html") + }} + end + + def get("https://shitposter.club/api/statuses/show/7369654.atom", _body, _headers) do + {:ok, %Response{ + status_code: 200, + body: File.read!("test/fixtures/httpoison_mock/7369654.atom") + }} + end + def get(url, body, headers) do {:error, "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{inspect(headers)}"} end diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 4aeabc596..8a7f328c3 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -288,6 +288,14 @@ test "it works with objects only available via Ostatus" do assert object == object_again end + + test "it correctly stitches up conversations between ostatus and ap" do + last = "https://mstdn.io/users/mayuutann/statuses/99568293732299394" + {:ok, object} = ActivityPub.fetch_object_from_id(last) + + object = Object.get_by_ap_id(object.data["inReplyTo"]) + assert object + end end describe "following / unfollowing" do diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 4d800992a..e3a170e4e 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -10,11 +10,6 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do alias Pleroma.Web.CommonAPI describe "handle_incoming" do - - test "it correctly connects AP and non-AP statuses" do - last = "https://mstdn.io/users/mayuutann/statuses/99568293732299394" - end - test "it ignores an incoming notice if we already have it" do activity = insert(:note_activity)