Mastodon Conversation API: Don't return own account in 'accounts'.
authorlain <lain@soykaf.club>
Fri, 31 May 2019 09:27:14 +0000 (11:27 +0200)
committerlain <lain@soykaf.club>
Fri, 31 May 2019 09:27:14 +0000 (11:27 +0200)
lib/pleroma/web/mastodon_api/views/conversation_view.ex
test/web/mastodon_api/mastodon_api_controller_test.exs

index 8e8f7cf31973d7b0ce1e8ab653adb4d55760d688..af1dcf66dd7588856551d2bee1e8f26b3ace7ca2 100644 (file)
@@ -22,9 +22,14 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
 
     last_status = StatusView.render("status.json", %{activity: activity, for: user})
 
+    # Conversations return all users except the current user.
+    users =
+      participation.conversation.users
+      |> Enum.reject(&(&1.id == user.id))
+
     accounts =
       AccountView.render("accounts.json", %{
-        users: participation.conversation.users,
+        users: users,
         as: :user
       })
 
index 1d9f5a816c084551fe1a4399b0a6fbbd6a901203..24cc911c33b226567305d53933cae26759ce9883 100644 (file)
@@ -317,12 +317,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
   test "Conversations", %{conn: conn} do
     user_one = insert(:user)
     user_two = insert(:user)
+    user_three = insert(:user)
 
     {:ok, user_two} = User.follow(user_two, user_one)
 
     {:ok, direct} =
       CommonAPI.post(user_one, %{
-        "status" => "Hi @#{user_two.nickname}!",
+        "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
         "visibility" => "direct"
       })
 
@@ -348,7 +349,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
              }
            ] = response
 
+    account_ids = Enum.map(res_accounts, & &1["id"])
     assert length(res_accounts) == 2
+    assert user_two.id in account_ids
+    assert user_three.id in account_ids
     assert is_binary(res_id)
     assert unread == true
     assert res_last_status["id"] == direct.id