Merge branch 'align-mastodon-conversations' into 'develop'

Mastodon Conversations API: Align to Mastodon behavior

See merge request pleroma/pleroma!1215
This commit is contained in:
lambda 2019-06-03 09:48:37 +00:00
commit 314758c25b
2 changed files with 11 additions and 2 deletions

View File

@ -22,9 +22,14 @@ def render("participation.json", %{participation: participation, user: user}) do
last_status = StatusView.render("status.json", %{activity: activity, for: user}) 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 = accounts =
AccountView.render("accounts.json", %{ AccountView.render("accounts.json", %{
users: participation.conversation.users, users: users,
as: :user as: :user
}) })

View File

@ -317,12 +317,13 @@ test "direct timeline", %{conn: conn} do
test "Conversations", %{conn: conn} do test "Conversations", %{conn: conn} do
user_one = insert(:user) user_one = insert(:user)
user_two = insert(:user) user_two = insert(:user)
user_three = insert(:user)
{:ok, user_two} = User.follow(user_two, user_one) {:ok, user_two} = User.follow(user_two, user_one)
{:ok, direct} = {:ok, direct} =
CommonAPI.post(user_one, %{ CommonAPI.post(user_one, %{
"status" => "Hi @#{user_two.nickname}!", "status" => "Hi @#{user_two.nickname}, @#{user_three.nickname}!",
"visibility" => "direct" "visibility" => "direct"
}) })
@ -348,7 +349,10 @@ test "Conversations", %{conn: conn} do
} }
] = response ] = response
account_ids = Enum.map(res_accounts, & &1["id"])
assert length(res_accounts) == 2 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 is_binary(res_id)
assert unread == true assert unread == true
assert res_last_status["id"] == direct.id assert res_last_status["id"] == direct.id