aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/web/ostatus/activity_representer.ex2
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex8
-rw-r--r--test/fixtures/incoming_note_activity_answer.xml42
-rw-r--r--test/web/ostatus/activity_representer_test.exs2
-rw-r--r--test/web/ostatus/ostatus_test.exs10
5 files changed, 62 insertions, 2 deletions
diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex
index 367212fe1..30e695bcc 100644
--- a/lib/pleroma/web/ostatus/activity_representer.ex
+++ b/lib/pleroma/web/ostatus/activity_representer.ex
@@ -15,7 +15,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
[
{:"activity:object-type", ['http://activitystrea.ms/schema/1.0/note']},
{:"activity:verb", ['http://activitystrea.ms/schema/1.0/post']},
- {:id, h.(activity.data["object"]["id"])},
+ {:id, h.(activity.data["id"])},
{:title, ['New note by #{user.nickname}']},
{:content, [type: 'html'], h.(activity.data["object"]["content"])},
{:published, h.(inserted_at)},
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index 65141f826..5b68f057e 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -65,6 +65,14 @@ defmodule Pleroma.Web.OStatus do
"actor" => actor.ap_id
}
+ inReplyTo = string_from_xpath("/entry/thr:in-reply-to[1]/@href", doc)
+
+ object = if inReplyTo do
+ Map.put(object, "inReplyTo", inReplyTo)
+ else
+ object
+ end
+
ActivityPub.create(to, actor, context, object, %{}, date)
end
diff --git a/test/fixtures/incoming_note_activity_answer.xml b/test/fixtures/incoming_note_activity_answer.xml
new file mode 100644
index 000000000..b1244faa6
--- /dev/null
+++ b/test/fixtures/incoming_note_activity_answer.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?><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:georss="http://www.georss.org/georss" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:statusnet="http://status.net/schema/api/1/">
+ <activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
+ <id>tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note</id>
+ <title>New note by lambda</title>
+ <content type="html">hey.</content>
+ <link rel="alternate" type="text/html" href="http://gs.example.org:4040/index.php/notice/55"/>
+ <status_net notice_id="55"></status_net>
+ <activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
+ <published>2017-04-25T18:16:13+00:00</published>
+ <updated>2017-04-25T18:16:13+00:00</updated>
+ <author>
+ <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
+ <uri>http://gs.example.org:4040/index.php/user/1</uri>
+ <name>lambda</name>
+ <link rel="alternate" type="text/html" href="http://gs.example.org:4040/index.php/lambda"/>
+ <link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png"/>
+ <link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://gs.example.org:4040/theme/neo-gnu/default-avatar-stream.png"/>
+ <link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://gs.example.org:4040/theme/neo-gnu/default-avatar-mini.png"/>
+ <poco:preferredUsername>lambda</poco:preferredUsername>
+ <poco:displayName>lambda</poco:displayName>
+ <followers url="http://gs.example.org:4040/index.php/lambda/subscribers"></followers>
+ <statusnet:profile_info local_id="1"></statusnet:profile_info>
+ </author>
+ <thr:in-reply-to ref="http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc" href="http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"></thr:in-reply-to>
+ <link rel="related" href="http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"/>
+ <link rel="ostatus:conversation" href="http://pleroma.example.org:4000/contexts/8f6f45d4-8e4d-4e1a-a2de-09f27367d2d0"/>
+ <ostatus:conversation>http://pleroma.example.org:4000/contexts/8f6f45d4-8e4d-4e1a-a2de-09f27367d2d0</ostatus:conversation>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/person" href="http://pleroma.example.org:4000/users/lain5"/>
+ <link rel="mentioned" ostatus:object-type="http://activitystrea.ms/schema/1.0/collection" href="http://activityschema.org/collection/public"/>
+ <source>
+ <id>http://gs.example.org:4040/index.php/api/statuses/user_timeline/1.atom</id>
+ <title>lambda</title>
+ <link rel="alternate" type="text/html" href="http://gs.example.org:4040/index.php/lambda"/>
+ <link rel="self" type="application/atom+xml" href="http://gs.example.org:4040/index.php/api/statuses/user_timeline/1.atom"/>
+ <link rel="license" href="https://creativecommons.org/licenses/by/3.0/"/>
+ <icon>http://gs.example.org:4040/theme/neo-gnu/default-avatar-profile.png</icon>
+ <updated>2017-04-25T18:16:13+00:00</updated>
+ </source>
+ <link rel="self" type="application/atom+xml" href="http://gs.example.org:4040/index.php/api/statuses/show/55.atom"/>
+ <link rel="edit" type="application/atom+xml" href="http://gs.example.org:4040/index.php/api/statuses/show/55.atom"/>
+ <statusnet:notice_info local_id="55" source="web"></statusnet:notice_info>
+</entry>
diff --git a/test/web/ostatus/activity_representer_test.exs b/test/web/ostatus/activity_representer_test.exs
index 10f9a9d0b..6cea9cff0 100644
--- a/test/web/ostatus/activity_representer_test.exs
+++ b/test/web/ostatus/activity_representer_test.exs
@@ -18,7 +18,7 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
expected = """
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
- <id>#{note_activity.data["object"]["id"]}</id>
+ <id>#{note_activity.data["id"]}</id>
<title>New note by #{user.nickname}</title>
<content type="html">#{note_activity.data["object"]["content"]}</content>
<published>#{inserted_at}</published>
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index dffebf5a7..96f2cb4f3 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -13,6 +13,16 @@ defmodule Pleroma.Web.OStatusTest do
assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
end
+ test "handle incoming replies" do
+ incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
+ {:ok, activity} = OStatus.handle_incoming(incoming)
+
+ assert activity.data["type"] == "Create"
+ assert activity.data["object"]["type"] == "Note"
+ assert activity.data["object"]["inReplyTo"] == "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
+ assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
+ end
+
describe "new remote user creation" do
test "make new user or find them based on an 'author' xml doc" do
incoming = File.read!("test/fixtures/user_name_only.xml")