diff options
author | lain <lain@soykaf.club> | 2020-06-03 14:26:50 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-03 14:26:50 +0200 |
commit | 7f5c5b11a5baeddec36ccc01b4954ac8aa9f8590 (patch) | |
tree | c175d81013de59da38cc8008e7122c4e6adf7304 /test/web/pleroma_api/controllers/chat_controller_test.exs | |
parent | 8edead7c1dc33457dc30b301b544d71482ef0f28 (diff) | |
download | pleroma-7f5c5b11a5baeddec36ccc01b4954ac8aa9f8590.tar.gz pleroma-7f5c5b11a5baeddec36ccc01b4954ac8aa9f8590.zip |
Chats: Remove `unread` from the db, calculate from unseen messages.
Diffstat (limited to 'test/web/pleroma_api/controllers/chat_controller_test.exs')
-rw-r--r-- | test/web/pleroma_api/controllers/chat_controller_test.exs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/test/web/pleroma_api/controllers/chat_controller_test.exs b/test/web/pleroma_api/controllers/chat_controller_test.exs index bd4024c09..e62b71799 100644 --- a/test/web/pleroma_api/controllers/chat_controller_test.exs +++ b/test/web/pleroma_api/controllers/chat_controller_test.exs @@ -19,9 +19,12 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do test "it marks all messages in a chat as read", %{conn: conn, user: user} do other_user = insert(:user) - {:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id) + {:ok, create} = CommonAPI.post_chat_message(other_user, user, "sup") + {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id) + object = Object.normalize(create, false) + cm_ref = ChatMessageReference.for_chat_and_object(chat, object) - assert chat.unread == 1 + assert cm_ref.seen == false result = conn @@ -30,9 +33,9 @@ defmodule Pleroma.Web.PleromaAPI.ChatControllerTest do assert result["unread"] == 0 - {:ok, chat} = Chat.get_or_create(user.id, other_user.ap_id) + cm_ref = ChatMessageReference.for_chat_and_object(chat, object) - assert chat.unread == 0 + assert cm_ref.seen == true end end |