Return statusnet_conversation_id in TwAPI.
authorRoger Braun <roger@rogerbraun.net>
Tue, 28 Mar 2017 12:49:21 +0000 (14:49 +0200)
committerRoger Braun <roger@rogerbraun.net>
Tue, 28 Mar 2017 12:49:21 +0000 (14:49 +0200)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
lib/pleroma/web/twitter_api/twitter_api.ex
test/web/twitter_api/representers/activity_representer_test.exs
test/web/twitter_api/twitter_api_test.exs

index 3b06830430f5f7ee0128e164cd9eaf8c9f6b965e..05d1306390592abc836374a13be8363c5808c148 100644 (file)
@@ -15,7 +15,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "is_local" => true,
       "is_post_verb" => true,
       "created_at" => published,
-      "in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"]
+      "in_reply_to_status_id" => activity.data["object"]["inReplyToStatusId"],
+      "statusnet_conversation_id" => activity.data["object"]["statusnetConversationId"]
     }
   end
 end
index 7bbab14c5665852c8e143bde11d28df470f1c152..07893e5650335cf253679fbefb1d3fa0d1e8c7c1 100644 (file)
@@ -34,8 +34,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
                |> put_in(["object", "context"], context)
                |> put_in(["object", "inReplyTo"], inReplyTo.data["object"]["id"])
                |> put_in(["object", "inReplyToStatusId"], inReplyToId)
-               |> put_in(["statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
-               |> put_in(["object", "statusnet_conversation_id"], inReplyTo.data["statusnet_conversation_id"])
+               |> put_in(["statusnetConversationId"], inReplyTo.data["statusnetConversationId"])
+               |> put_in(["object", "statusnetConversationId"], inReplyTo.data["statusnetConversationId"])
                else _e ->
                  activity
                end
@@ -72,12 +72,12 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
   end
 
   defp add_conversation_id(activity) do
-    if is_integer(activity.data["statusnet_conversation_id"]) do
+    if is_integer(activity.data["statusnetConversationId"]) do
       {:ok, activity}
     else
       data = activity.data
-      |> put_in(["object", "statusnet_conversation_id"], activity.id)
-      |> put_in(["statusnet_conversation_id"], activity.id)
+      |> put_in(["object", "statusnetConversationId"], activity.id)
+      |> put_in(["statusnetConversationId"], activity.id)
 
       changeset = Ecto.Changeset.change(activity, data: data)
       Repo.update(changeset)
index b6510111529f029ea5d1533c7645341b57420e0b..376d315755149542c3032dad3e4655a3b60f327a 100644 (file)
@@ -24,7 +24,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
           "published" => date,
           "type" => "Note",
           "content" => content,
-          "inReplyToStatusId" => 213123
+          "inReplyToStatusId" => 213123,
+          "statusnetConversationId" => 4711
         },
         "published" => date
       }
@@ -40,7 +41,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "text" => content,
       "is_post_verb" => true,
       "created_at" => date,
-      "in_reply_to_status_id" => 213123
+      "in_reply_to_status_id" => 213123,
+      "statusnet_conversation_id" => 4711
     }
 
     assert ActivityRepresenter.to_map(activity, %{user: user, for: follower}) == expected_status
index e7c180a9c641b27e446aaa42bdef16d7cd2c014e..381a9fa5b4c927df52087d6d83f612c7eb63b746 100644 (file)
@@ -22,8 +22,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
     # Add a context + 'statusnet_conversation_id'
     assert is_binary(get_in(activity.data, ["context"]))
     assert is_binary(get_in(activity.data, ["object", "context"]))
-    assert get_in(activity.data, ["object", "statusnet_conversation_id"]) == activity.id
-    assert get_in(activity.data, ["statusnet_conversation_id"]) == activity.id
+    assert get_in(activity.data, ["object", "statusnetConversationId"]) == activity.id
+    assert get_in(activity.data, ["statusnetConversationId"]) == activity.id
   end
 
   test "create a status that is a reply" do
@@ -43,8 +43,8 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
 
     assert get_in(reply.data, ["context"]) == get_in(activity.data, ["context"])
     assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])
-    assert get_in(reply.data, ["statusnet_conversation_id"]) == get_in(activity.data, ["statusnet_conversation_id"])
-    assert get_in(reply.data, ["object", "statusnet_conversation_id"]) == get_in(activity.data, ["object", "statusnet_conversation_id"])
+    assert get_in(reply.data, ["statusnetConversationId"]) == get_in(activity.data, ["statusnetConversationId"])
+    assert get_in(reply.data, ["object", "statusnetConversationId"]) == get_in(activity.data, ["object", "statusnetConversationId"])
     assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])
     assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id
   end