Add activity_type to twitter api output.
authorRoger Braun <roger@rogerbraun.net>
Thu, 24 Aug 2017 14:18:26 +0000 (16:18 +0200)
committerRoger Braun <roger@rogerbraun.net>
Thu, 24 Aug 2017 14:18:26 +0000 (16:18 +0200)
lib/pleroma/web/twitter_api/representers/activity_representer.ex
test/web/twitter_api/representers/activity_representer_test.exs

index 10aab919a74ef1beb91fbb1802ab4944f42b22e7..16a2f6810d1d7feb90cf0187ad37dcc544c2f22a 100644 (file)
@@ -29,7 +29,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "created_at" => created_at,
       "retweeted_status" => retweeted_status,
       "statusnet_conversation_id" => conversation_id(announced_activity),
-      "external_url" => activity.data["id"]
+      "external_url" => activity.data["id"],
+      "activity_type" => "repeat"
     }
   end
 
@@ -49,7 +50,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "uri" => "tag:#{activity.data["id"]}:objectType=Favourite",
       "created_at" => created_at,
       "in_reply_to_status_id" => liked_activity.id,
-      "external_url" => activity.data["id"]
+      "external_url" => activity.data["id"],
+      "activity_type" => "like"
     }
   end
 
@@ -68,7 +70,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "is_post_verb" => false,
       "created_at" => created_at,
       "in_reply_to_status_id" => nil,
-      "external_url" => activity.data["id"]
+      "external_url" => activity.data["id"],
+      "activity_type" => "follow"
     }
   end
 
@@ -88,7 +91,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "is_post_verb" => false,
       "created_at" => created_at,
       "in_reply_to_status_id" => nil,
-      "external_url" => activity.data["id"]
+      "external_url" => activity.data["id"],
+      "activity_type" => "undo"
     }
   end
 
@@ -125,7 +129,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenter do
       "favorited" => to_boolean(favorited),
       "repeated" => to_boolean(repeated),
       "external_url" => object["external_url"],
-      "tags" => activity.data["object"]["tag"] || []
+      "tags" => activity.data["object"]["tag"] || [],
+      "activity_type" => "post"
     }
   end
 
index e9f6a1915c2e8f9fdf7c9981d3d79ba277726151..f9998e614922f165354613b63de22dee8af8c7ac 100644 (file)
@@ -27,6 +27,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
     assert status["statusnet_conversation_id"] == retweeted_status["statusnet_conversation_id"]
 
     assert status["retweeted_status"] == retweeted_status
+    assert status["activity_type"] == "repeat"
   end
 
   test "a like activity" do
@@ -44,6 +45,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
     activity_actor = Repo.get_by(User, ap_id: note_activity.data["actor"])
     liked_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user})
     assert liked_status["favorited"] == true
+    assert status["activity_type"] == "like"
   end
 
   test "an activity" do
@@ -127,7 +129,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "favorited" => false,
       "repeated" => false,
       "external_url" => "some url",
-      "tags" => ["content", "mentioning", "nsfw"]
+      "tags" => ["content", "mentioning", "nsfw"],
+      "activity_type" => "post"
     }
 
     assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status
@@ -142,5 +145,6 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
 
     map = ActivityRepresenter.to_map(unfollow, %{user: follower})
     assert map["is_post_verb"] == false
+    assert map["activity_type"] == "undo"
   end
 end