forked from AkkomaGang/akkoma
Handle incoming follows.
Also Mastodon CWs.
This commit is contained in:
parent
34a1ce00ec
commit
05f2cd0d93
8 changed files with 427 additions and 4 deletions
16
lib/pleroma/web/ostatus/handlers/follow_handler.ex
Normal file
16
lib/pleroma/web/ostatus/handlers/follow_handler.ex
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
defmodule Pleroma.Web.OStatus.FollowHandler do
|
||||||
|
alias Pleroma.Web.{XML, OStatus}
|
||||||
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
alias Pleroma.User
|
||||||
|
|
||||||
|
def handle(entry, doc) do
|
||||||
|
with {:ok, actor} <- OStatus.find_make_or_update_user(doc),
|
||||||
|
id when not is_nil(id) <- XML.string_from_xpath("/entry/id", entry),
|
||||||
|
followed_uri when not is_nil(followed_uri) <- XML.string_from_xpath("/entry/activity:object/id", entry),
|
||||||
|
{:ok, followed} <- OStatus.find_or_make_user(followed_uri),
|
||||||
|
{:ok, activity} <- ActivityPub.follow(actor, followed, id, false) do
|
||||||
|
User.follow(actor, followed)
|
||||||
|
{:ok, activity}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.OStatus do
|
||||||
alias Pleroma.{Repo, User, Web, Object, Activity}
|
alias Pleroma.{Repo, User, Web, Object, Activity}
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.{WebFinger, Websub}
|
alias Pleroma.Web.{WebFinger, Websub}
|
||||||
|
alias Pleroma.Web.OStatus.FollowHandler
|
||||||
|
|
||||||
def feed_path(user) do
|
def feed_path(user) do
|
||||||
"#{user.ap_id}/feed.atom"
|
"#{user.ap_id}/feed.atom"
|
||||||
|
@ -30,6 +31,8 @@ def handle_incoming(xml_string) do
|
||||||
{:xmlObj, :string, verb} = :xmerl_xpath.string('string(/entry/activity:verb[1])', entry)
|
{:xmlObj, :string, verb} = :xmerl_xpath.string('string(/entry/activity:verb[1])', entry)
|
||||||
|
|
||||||
case verb do
|
case verb do
|
||||||
|
'http://activitystrea.ms/schema/1.0/follow' ->
|
||||||
|
with {:ok, activity} <- FollowHandler.handle(entry, doc), do: activity
|
||||||
'http://activitystrea.ms/schema/1.0/share' ->
|
'http://activitystrea.ms/schema/1.0/share' ->
|
||||||
with {:ok, activity, retweeted_activity} <- handle_share(entry, doc), do: [activity, retweeted_activity]
|
with {:ok, activity, retweeted_activity} <- handle_share(entry, doc), do: [activity, retweeted_activity]
|
||||||
'http://activitystrea.ms/schema/1.0/favorite' ->
|
'http://activitystrea.ms/schema/1.0/favorite' ->
|
||||||
|
@ -116,8 +119,18 @@ def get_attachments(entry) do
|
||||||
|> Enum.filter(&(&1))
|
|> Enum.filter(&(&1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_content(entry) do
|
||||||
|
base_content = string_from_xpath("/entry/content", entry)
|
||||||
|
|
||||||
|
with scope when not is_nil(scope) <- string_from_xpath("//mastodon:scope", entry),
|
||||||
|
cw when not is_nil(cw) <- string_from_xpath("/entry/summary", entry) do
|
||||||
|
"<span class='mastodon-cw'>#{cw}</span><br>#{base_content}"
|
||||||
|
else _e -> base_content
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def handle_note(entry, doc \\ nil) do
|
def handle_note(entry, doc \\ nil) do
|
||||||
content_html = string_from_xpath("//content[1]", entry)
|
content_html = get_content(entry)
|
||||||
|
|
||||||
[author] = :xmerl_xpath.string('//author[1]', doc)
|
[author] = :xmerl_xpath.string('//author[1]', doc)
|
||||||
{:ok, actor} = find_make_or_update_user(author)
|
{:ok, actor} = find_make_or_update_user(author)
|
||||||
|
|
68
test/fixtures/follow.xml
vendored
Normal file
68
test/fixtures/follow.xml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?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-07T09:54:49+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-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00</id>
|
||||||
|
<title>Constance Variable (lambadalambda@social.heldscal.la)'s status on Sunday, 07-May-2017 09:54:49 UTC</title>
|
||||||
|
<content type="html"><a href="https://social.heldscal.la/lambadalambda">Constance Variable</a> started following <a href="https://pawoo.net/@pekorino">mono</a>.</content>
|
||||||
|
<link rel="alternate" type="text/html" href="https://social.heldscal.la/notice/2092981"/>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/follow</activity:verb>
|
||||||
|
<published>2017-05-07T09:54:49+00:00</published>
|
||||||
|
<updated>2017-05-07T09:54:49+00:00</updated>
|
||||||
|
<activity:object>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
||||||
|
<id>https://pawoo.net/users/pekorino</id>
|
||||||
|
<title>mono</title>
|
||||||
|
<summary>http://shitposter.club/mono 孤独のグルメ</summary>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/@pekorino"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://social.heldscal.la/theme/neo-gnu/default-avatar-profile.png"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://social.heldscal.la/theme/neo-gnu/default-avatar-stream.png"/>
|
||||||
|
<link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://social.heldscal.la/theme/neo-gnu/default-avatar-mini.png"/>
|
||||||
|
<poco:preferredUsername>pekorino</poco:preferredUsername>
|
||||||
|
<poco:displayName>mono</poco:displayName>
|
||||||
|
<poco:note>http://shitposter.club/mono 孤独のグルメ</poco:note>
|
||||||
|
</activity:object>
|
||||||
|
<link rel="ostatus:conversation" href="https://social.heldscal.la/conversation/1079786"/>
|
||||||
|
<ostatus:conversation href="https://social.heldscal.la/conversation/1079786" local_id="1079786" ref="tag:social.heldscal.la,2017-05-07:objectType=thread:nonce=6e80caf94e03029f">tag:social.heldscal.la,2017-05-07:objectType=thread:nonce=6e80caf94e03029f</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/2092981.atom"/>
|
||||||
|
<link rel="edit" type="application/atom+xml" href="https://social.heldscal.la/api/statuses/show/2092981.atom"/>
|
||||||
|
<statusnet:notice_info local_id="2092981" source="activity"></statusnet:notice_info>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
231
test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom
vendored
Normal file
231
test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom
vendored
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<feed 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>https://pawoo.net/users/pekorino.atom</id>
|
||||||
|
<title>モノエ</title>
|
||||||
|
<subtitle>シアトル・米国
|
||||||
|
|
||||||
|
GNUsocial 英語版
|
||||||
|
http://shitposter.club/mono
|
||||||
|
|
||||||
|
</subtitle>
|
||||||
|
<updated>2017-05-07T09:28:20Z</updated>
|
||||||
|
<logo>https://img.pawoo.net/accounts/avatars/000/128/378/original/e1fce04a36a1ad90.jpg</logo>
|
||||||
|
<author>
|
||||||
|
<id>https://pawoo.net/users/pekorino</id>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
||||||
|
<uri>https://pawoo.net/users/pekorino</uri>
|
||||||
|
<name>pekorino</name>
|
||||||
|
<email>pekorino@pawoo.net</email>
|
||||||
|
<summary type="html"><p>シアトル・米国</p><p>GNUsocial 英語版<br /><a href="http://shitposter.club/mono" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">shitposter.club/mono</span><span class="invisible"></span></a> </p></summary>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/@pekorino"/>
|
||||||
|
<link rel="avatar" type="image/jpeg" media:width="120" media:height="120" href="https://img.pawoo.net/accounts/avatars/000/128/378/original/e1fce04a36a1ad90.jpg"/>
|
||||||
|
<link rel="header" type="image/png" media:width="700" media:height="335" href="https://img.pawoo.net/accounts/headers/000/128/378/original/bae3502120206e68.png"/>
|
||||||
|
<poco:preferredUsername>pekorino</poco:preferredUsername>
|
||||||
|
<poco:displayName>モノエ</poco:displayName>
|
||||||
|
<poco:note>シアトル・米国
|
||||||
|
|
||||||
|
GNUsocial 英語版
|
||||||
|
http://shitposter.club/mono
|
||||||
|
|
||||||
|
</poco:note>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
</author>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/@pekorino"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino.atom"/>
|
||||||
|
<link rel="hub" href="https://pawoo.net/api/push"/>
|
||||||
|
<link rel="salmon" href="https://pawoo.net/api/salmon/128378"/>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9319211:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:56:35Z</published>
|
||||||
|
<updated>2017-05-07T09:56:35Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/moonman" class="u-url mention">@<span>moonman</span></a></span> <span class="h-card"><a href="https://shitposter.club/rw" class="u-url mention">@<span>rw</span></a></span> <span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> <span class="h-card"><a href="https://shitposter.club/mono" class="u-url mention">@<span>mono</span></a></span> </p><p>i have to wait for someone to respond to this before i can follow because i dont think this software has a direct follow by url option</p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9056"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://social.heldscal.la/user/23211"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/666"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/1"/>
|
||||||
|
<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://pawoo.net/users/pekorino/updates/2496950"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2496950.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:pawoo.net,2017-05-07:objectId=9318595:objectType=Status" href="https://pawoo.net/@pekorino/9318595"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9318595:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:54:39Z</published>
|
||||||
|
<updated>2017-05-07T09:54:39Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/mono" class="u-url mention">@<span>mono</span></a></span> <span class="h-card"><a href="https://social.heldscal.la/lambadalambda" class="u-url mention">@<span>lambadalambda</span></a></span> <span class="h-card"><a href="https://shitposter.club/rw" class="u-url mention">@<span>rw</span></a></span> <span class="h-card"><a href="https://shitposter.club/moonman" class="u-url mention">@<span>moonman</span></a></span> <br />please respond</p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/1"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/666"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://social.heldscal.la/user/23211"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9056"/>
|
||||||
|
<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://pawoo.net/users/pekorino/updates/2496838"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2496838.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:shitposter.club,2017-05-07:noticeId=2856143:objectType=note" href="https://shitposter.club/notice/2856143"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9313978:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:39:17Z</published>
|
||||||
|
<updated>2017-05-07T09:39:17Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p><span class="h-card"><a href="https://shitposter.club/moonman" class="u-url mention">@<span>moonman</span></a></span> <br />mastodon is so slow. browser crashed twice trying to set avatar</p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/1"/>
|
||||||
|
<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://pawoo.net/users/pekorino/updates/2496065"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2496065.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9312691:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:34:38Z</published>
|
||||||
|
<updated>2017-05-07T09:34:38Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/hardbass2k8" class="u-url mention">@<span>hardbass2k8</span></a></span> <a href="https://pawoo.net/media/mZJjLpbPU72GFEz2Svk" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">pawoo.net/media/mZJjLpbPU72GFE</span><span class="invisible">z2Svk</span></a></p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9591"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||||
|
<link rel="enclosure" type="image/jpeg" length="42074" href="https://img.pawoo.net/media_attachments/files/000/681/737/original/483a0d76fce39156.jpg"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/users/pekorino/updates/2495835"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2495835.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:shitposter.club,2017-05-07:noticeId=2855897:objectType=note" href="https://shitposter.club/notice/2855897"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9312379:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:33:29Z</published>
|
||||||
|
<updated>2017-05-07T09:33:29Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/hardbass2k8" class="u-url mention">@<span>hardbass2k8</span></a></span> <a href="https://pawoo.net/media/nt5JHBEHyTN2bqzdcGU" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">pawoo.net/media/nt5JHBEHyTN2bq</span><span class="invisible">zdcGU</span></a></p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9591"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||||
|
<link rel="enclosure" type="image/png" length="8605" href="https://img.pawoo.net/media_attachments/files/000/681/714/original/1e3f216d4f78c69d.png"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/users/pekorino/updates/2495772"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2495772.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:shitposter.club,2017-05-07:noticeId=2855886:objectType=comment" href="https://shitposter.club/notice/2855886"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9311765:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:31:26Z</published>
|
||||||
|
<updated>2017-05-07T09:31:26Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p><a href="https://pawoo.net/media/C4RV6ubsEtvS04DX6qs" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">pawoo.net/media/C4RV6ubsEtvS04</span><span class="invisible">DX6qs</span></a></p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||||
|
<link rel="enclosure" type="image/jpeg" length="71196" href="https://img.pawoo.net/media_attachments/files/000/681/667/original/dc310e8fd312e7ff.jpg"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/users/pekorino/updates/2495666"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2495666.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9311610:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:30:59Z</published>
|
||||||
|
<updated>2017-05-07T09:30:59Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p><a href="https://pawoo.net/media/MBmkeEdrjs8pAtCHN6s" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">pawoo.net/media/MBmkeEdrjs8pAt</span><span class="invisible">CHN6s</span></a></p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||||
|
<link rel="enclosure" type="image/jpeg" length="158377" href="https://img.pawoo.net/media_attachments/files/000/681/656/original/7e2d78ecfd243e67.jpg"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/users/pekorino/updates/2495632"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2495632.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9307782:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:16:47Z</published>
|
||||||
|
<updated>2017-05-07T09:16:47Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p><span class="h-card"><a href="https://shitposter.club/mono" class="u-url mention">@<span>mono</span></a></span></p><p>test</p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9056"/>
|
||||||
|
<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://pawoo.net/users/pekorino/updates/2494966"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2494966.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9307444:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:15:42Z</published>
|
||||||
|
<updated>2017-05-07T09:15:42Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/hardbass2k8" class="u-url mention">@<span>hardbass2k8</span></a></span> テスト</p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9591"/>
|
||||||
|
<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://pawoo.net/users/pekorino/updates/2494900"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2494900.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:shitposter.club,2017-05-07:noticeId=2855867:objectType=note" href="https://shitposter.club/notice/2855867"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-05-07:objectId=9307239:objectType=Status</id>
|
||||||
|
<published>2017-05-07T09:14:58Z</published>
|
||||||
|
<updated>2017-05-07T09:14:58Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p>ててててててテスト</p></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://pawoo.net/users/pekorino/updates/2494866"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/2494866.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-04-20:objectId=2212164:objectType=Status</id>
|
||||||
|
<published>2017-04-20T06:19:18Z</published>
|
||||||
|
<updated>2017-04-20T06:19:18Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/comment</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<content type="html" xml:lang="en"><p><span class="h-card"><a href="https://shitposter.club/mono" class="u-url mention">@<span>mono</span></a></span> <a href="https://pawoo.net/media/iMbjMBVPfZJX3lUC2Sc" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">pawoo.net/media/iMbjMBVPfZJX3l</span><span class="invisible">UC2Sc</span></a></p></content>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="https://shitposter.club/user/9056"/>
|
||||||
|
<link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
|
||||||
|
<link rel="enclosure" type="image/png" length="754410" href="https://img.pawoo.net/media_attachments/files/000/199/926/original/f11a4c9c91403766.png"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://pawoo.net/users/pekorino/updates/874763"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/874763.atom"/>
|
||||||
|
<thr:in-reply-to ref="tag:shitposter.club,2017-04-20:noticeId=2570261:objectType=note" href="https://shitposter.club/notice/2570261"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-04-20:objectId=2206216:objectType=Status</id>
|
||||||
|
<published>2017-04-20T05:57:59Z</published>
|
||||||
|
<updated>2017-04-20T05:57:59Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p>テスト</p></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://pawoo.net/users/pekorino/updates/872900"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/872900.atom"/>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<id>tag:pawoo.net,2017-04-20:objectId=2204702:objectType=Status</id>
|
||||||
|
<published>2017-04-20T05:52:09Z</published>
|
||||||
|
<updated>2017-04-20T05:52:09Z</updated>
|
||||||
|
<title>New status by pekorino</title>
|
||||||
|
<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"><p>HELLOWORLD</p></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://pawoo.net/users/pekorino/updates/872464"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://pawoo.net/users/pekorino/updates/872464.atom"/>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
11
test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml
vendored
Normal file
11
test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||||
|
<Subject>acct:pekorino@pawoo.net</Subject>
|
||||||
|
<Alias>https://pawoo.net/@pekorino</Alias>
|
||||||
|
<Alias>https://pawoo.net/users/pekorino</Alias>
|
||||||
|
<Link rel="http://webfinger.net/rel/profile-page" type="text/html" href="https://pawoo.net/@pekorino"/>
|
||||||
|
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="https://pawoo.net/users/pekorino.atom"/>
|
||||||
|
<Link rel="salmon" href="https://pawoo.net/api/salmon/128378"/>
|
||||||
|
<Link rel="magic-public-key" href="data:application/magic-public-key,RSA.1x8XXmBqzyb-QRkfUKxKPd7Ac2KbaFhdKy2FkJY64G-ifga-BppzEb62Q5TdkRdVKdHjh5qI7A1Hk3KfnNQcNWqqak-jxII_txC2grbWpp7v-boceD2pnzdVK5l-RR-9wEwxcoCUeRWS1Ak6DStqE5tFQOAK4IIGQB-thSQGlU75KZ-2080fPA3Xc_ycH3_eB4YqawSxXrh6IeScMevN0YHSF84GAcvhXmwLKZRugiF6nYrknbPEe_niIOmN8hhEXLN9_4kDcH83hkVZd5VXssRrxqDhtokx9emvTHkA7sY1AjYeehTPZErlV74GN-kFYLeI6DluXoSI2sX1QcS08w==.AQAB"/>
|
||||||
|
<Link rel="http://ostatus.org/schema/1.0/subscribe" template="https://pawoo.net/authorize_follow?acct={uri}"/>
|
||||||
|
</XRD>
|
39
test/fixtures/mastodon-note-cw.xml
vendored
Normal file
39
test/fixtures/mastodon-note-cw.xml
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<feed 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>https://mastodon.social/users/lambadalambda.atom</id>
|
||||||
|
<title>Critical Value</title>
|
||||||
|
<subtitle></subtitle>
|
||||||
|
<updated>2017-04-16T21:47:25Z</updated>
|
||||||
|
<logo>https://files.mastodon.social/accounts/avatars/000/000/264/original/1429214160519.gif</logo>
|
||||||
|
<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>
|
||||||
|
<link rel="alternate" type="text/html" href="https://mastodon.social/@lambadalambda"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://mastodon.social/users/lambadalambda.atom"/>
|
||||||
|
<link rel="hub" href="https://mastodon.social/api/push"/>
|
||||||
|
<link rel="salmon" href="https://mastodon.social/api/salmon/264"/>
|
||||||
|
<entry>
|
||||||
|
<id>tag:mastodon.social,2017-05-10:objectId=5551985:objectType=Status</id>
|
||||||
|
<published>2017-05-10T12:21:36Z</published>
|
||||||
|
<updated>2017-05-10T12:21:36Z</updated>
|
||||||
|
<title>New status by lambadalambda</title>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<summary xml:lang="sv">technologic</summary>
|
||||||
|
<content type="html" xml:lang="sv"><p>test</p></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/2314748"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://mastodon.social/users/lambadalambda/updates/2314748.atom"/>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
|
@ -115,8 +115,28 @@ def get("https://shitposter.club/api/statuses/user_timeline/1.atom", _body, _hea
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post("https://social.heldscal.la/main/push/hub", {:form, data}, ["Content-type": "application/x-www-form-urlencoded"]) do
|
||||||
|
{:ok, %Response{
|
||||||
|
status_code: 202
|
||||||
|
}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get("https://pawoo.net/.well-known/webfinger", [Accept: "application/xrd+xml"], [params: [resource: "https://pawoo.net/users/pekorino"]]) do
|
||||||
|
{:ok, %Response{
|
||||||
|
status_code: 200,
|
||||||
|
body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.xml")
|
||||||
|
}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get("https://pawoo.net/users/pekorino.atom", _, _) do
|
||||||
|
{:ok, %Response{
|
||||||
|
status_code: 200,
|
||||||
|
body: File.read!("test/fixtures/httpoison_mock/https___pawoo.net_users_pekorino.atom")
|
||||||
|
}}
|
||||||
|
end
|
||||||
|
|
||||||
def get(url, body, headers) do
|
def get(url, body, headers) do
|
||||||
{:error, "Not implemented the mock response for get #{inspect(url)}"}
|
{:error, "Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{inspect(headers)}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def post(url, body, headers) do
|
def post(url, body, headers) do
|
||||||
|
|
|
@ -62,6 +62,16 @@ test "handle incoming notes - Mastodon, salmon, reply" do
|
||||||
assert activity.data["context"] == "2hu"
|
assert activity.data["context"] == "2hu"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "handle incoming notes - Mastodon, with CW" do
|
||||||
|
incoming = File.read!("test/fixtures/mastodon-note-cw.xml")
|
||||||
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||||
|
|
||||||
|
assert activity.data["type"] == "Create"
|
||||||
|
assert activity.data["object"]["type"] == "Note"
|
||||||
|
assert activity.data["object"]["actor"] == "https://mastodon.social/users/lambadalambda"
|
||||||
|
assert String.contains?(activity.data["object"]["content"], "technologic")
|
||||||
|
end
|
||||||
|
|
||||||
test "handle incoming notes - GS, subscription, reply" do
|
test "handle incoming notes - GS, subscription, reply" do
|
||||||
incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml")
|
incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml")
|
||||||
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||||
|
@ -172,6 +182,21 @@ test "handle incoming replies" do
|
||||||
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
assert activity.data["object"]["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "handle incoming follows" do
|
||||||
|
incoming = File.read!("test/fixtures/follow.xml")
|
||||||
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||||
|
assert activity.data["type"] == "Follow"
|
||||||
|
assert activity.data["id"] == "tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
|
||||||
|
assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
|
||||||
|
assert activity.data["object"] == "https://pawoo.net/users/pekorino"
|
||||||
|
refute activity.local
|
||||||
|
|
||||||
|
follower = User.get_cached_by_ap_id(activity.data["actor"])
|
||||||
|
followed = User.get_cached_by_ap_id(activity.data["object"])
|
||||||
|
|
||||||
|
assert User.following?(follower, followed)
|
||||||
|
end
|
||||||
|
|
||||||
describe "new remote user creation" do
|
describe "new remote user creation" do
|
||||||
test "returns local users" do
|
test "returns local users" do
|
||||||
local_user = insert(:user)
|
local_user = insert(:user)
|
||||||
|
|
Loading…
Reference in a new issue