Add ostatus conversation as context.
authorRoger Braun <roger@rogerbraun.net>
Tue, 25 Apr 2017 15:45:34 +0000 (17:45 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 25 Apr 2017 15:45:34 +0000 (17:45 +0200)
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/twitter_api/twitter_api.ex
test/web/ostatus/ostatus_test.exs

index 4fd649c92093575e6ba83e6abf1979ae2d6be122..8c31ce5aa3e872fe4a47d91adff3c4288d318bbf 100644 (file)
@@ -41,7 +41,12 @@ defmodule Pleroma.Web.OStatus do
     [author] = :xmerl_xpath.string('/entry/author[1]', doc)
     {:ok, actor} = find_or_make_user(author)
 
-    context = ActivityPub.generate_context_id
+    context = string_from_xpath("/entry/ostatus:conversation[1]", doc) |> String.trim
+    context = if String.length(context) > 0 do
+      context
+    else
+      ActivityPub.generate_context_id
+    end
 
     to = [
       "https://www.w3.org/ns/activitystreams#Public"
index cb48c7f5fb40fa094df1ba489d33e4d358193bf5..e4e26df1581cf09af5d8e01412d504391ec10333 100644 (file)
@@ -253,7 +253,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
       {:error, changeset} ->
         errors = Ecto.Changeset.traverse_errors(changeset, fn {msg, _opts} -> msg end)
       |> Poison.encode!
-        {:error, %{error: errors}}
+      {:error, %{error: errors}}
     end
   end
 
index 8ee605494b26ff090743174d044e6b74dc40405e..61dca54469d317fb02c8f2072d5e4ebc3e1783a1 100644 (file)
@@ -9,6 +9,7 @@ defmodule Pleroma.Web.OStatusTest do
     assert activity.data["type"] == "Create"
     assert activity.data["object"]["type"] == "Note"
     assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
+    assert activity.data["context"] == "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
   end
 
   describe "new remote user creation" do