Handle mastodon conversation ids.
This commit is contained in:
parent
485cc0bc6a
commit
1b1f861bad
3 changed files with 41 additions and 1 deletions
|
@ -24,7 +24,10 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
|
||||||
3. A newly generated context id.
|
3. A newly generated context id.
|
||||||
"""
|
"""
|
||||||
def get_context(entry, inReplyTo) do
|
def get_context(entry, inReplyTo) do
|
||||||
context = (XML.string_from_xpath("//ostatus:conversation[1]", entry) || "") |> String.trim
|
context = (
|
||||||
|
XML.string_from_xpath("//ostatus:conversation[1]", entry)
|
||||||
|
|| XML.string_from_xpath("//ostatus:conversation[1]/@ref", entry)
|
||||||
|
|| "") |> String.trim
|
||||||
|
|
||||||
with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(inReplyTo) do
|
with %{data: %{"context" => context}} <- Object.get_cached_by_ap_id(inReplyTo) do
|
||||||
context
|
context
|
||||||
|
|
30
test/fixtures/mastodon_conversation.xml
vendored
Normal file
30
test/fixtures/mastodon_conversation.xml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?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-08-28:objectId=16402826:objectType=Status</id>
|
||||||
|
<published>2017-08-28T17:58:55Z</published>
|
||||||
|
<updated>2017-08-28T17:58:55Z</updated>
|
||||||
|
<title>New status by lambadalambda</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="image/gif" media:width="700" media:height="335" href="https://files.mastodon.social/accounts/headers/000/000/264/original/28b26104f83747d2.gif"/>
|
||||||
|
<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/note</activity:object-type>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<link rel="alternate" type="application/activity+json" href="https://mastodon.social/users/lambadalambda/statuses/16402826"/>
|
||||||
|
<content type="html" xml:lang=""><p>test. <a href="https://mastodon.social/media/XCp0OHGPON9kWZwhjaI" rel="nofollow noopener" target="_blank"><span class="invisible">https://</span><span class="ellipsis">mastodon.social/media/XCp0OHGP</span><span class="invisible">ON9kWZwhjaI</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/png" length="307682" href="https://files.mastodon.social/media_attachments/files/001/271/957/original/6b426b164a09a40e.png"/>
|
||||||
|
<mastodon:scope>public</mastodon:scope>
|
||||||
|
<link rel="alternate" type="text/html" href="https://mastodon.social/users/lambadalambda/updates/4215320"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="https://mastodon.social/users/lambadalambda/updates/4215320.atom"/>
|
||||||
|
<ostatus:conversation ref="tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"/>
|
||||||
|
</entry>
|
|
@ -182,6 +182,13 @@ defmodule Pleroma.Web.OStatusTest do
|
||||||
refute favorited_activity.local
|
refute favorited_activity.local
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "handle conversation references" do
|
||||||
|
incoming = File.read!("test/fixtures/mastodon_conversation.xml")
|
||||||
|
{:ok, [activity]} = OStatus.handle_incoming(incoming)
|
||||||
|
|
||||||
|
assert activity.data["context"] == "tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"
|
||||||
|
end
|
||||||
|
|
||||||
test "handle incoming favorites with locally available object - GS, websub" do
|
test "handle incoming favorites with locally available object - GS, websub" do
|
||||||
note_activity = insert(:note_activity)
|
note_activity = insert(:note_activity)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue