Hide chats from muted users

This commit is contained in:
Egor Kislitsyn 2020-11-02 17:51:54 +04:00
commit be52819a11
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
2 changed files with 33 additions and 16 deletions

View file

@ -343,6 +343,28 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do
assert length(result) == 0
end
test "it does not return chats with users you muted", %{conn: conn, user: user} do
recipient = insert(:user)
{:ok, _} = Chat.get_or_create(user.id, recipient.ap_id)
result =
conn
|> get("/api/v1/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 1
User.mute(user, recipient)
result =
conn
|> get("/api/v1/pleroma/chats")
|> json_response_and_validate_schema(200)
assert length(result) == 0
end
test "it returns all chats", %{conn: conn, user: user} do
Enum.each(1..30, fn _ ->
recipient = insert(:user)