Add activity_type to twitter api output.
[akkoma] / test / web / twitter_api / representers / activity_representer_test.exs
index 781ef8536ff76bf60e1eb1fdc01bd80617d78f77..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
@@ -93,6 +95,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
           "attachment" => [
             object
           ],
+          "external_url" => "some url",
           "like_count" => 5,
           "announcement_count" => 3,
           "context" => "2hu",
@@ -100,14 +103,15 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
         },
         "published" => date,
         "context" => "2hu"
-      }
+      },
+      local: false
     }
 
 
     expected_status = %{
       "id" => activity.id,
       "user" => UserView.render("show.json", %{user: user, for: follower}),
-      "is_local" => true,
+      "is_local" => false,
       "statusnet_html" => HtmlSanitizeEx.basic_html(content_html),
       "text" => content,
       "is_post_verb" => true,
@@ -124,10 +128,23 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
       "repeat_num" => 3,
       "favorited" => false,
       "repeated" => false,
-      "external_url" => activity.data["id"],
-      "tags" => ["content", "mentioning", "nsfw"]
+      "external_url" => "some url",
+      "tags" => ["content", "mentioning", "nsfw"],
+      "activity_type" => "post"
     }
 
     assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status
   end
+
+  test "an undo for a follow" do
+    follower = insert(:user)
+    followed = insert(:user)
+
+    {:ok, follow} = ActivityPub.follow(follower, followed)
+    {:ok, unfollow} = ActivityPub.unfollow(follower, followed)
+
+    map = ActivityRepresenter.to_map(unfollow, %{user: follower})
+    assert map["is_post_verb"] == false
+    assert map["activity_type"] == "undo"
+  end
 end