Chats: Remove unread from the db, calculate from unseen messages.

This commit is contained in:
lain 2020-06-03 14:26:50 +02:00
commit 7f5c5b11a5
9 changed files with 40 additions and 30 deletions

View file

@ -6,7 +6,6 @@ defmodule Pleroma.ChatTest do
use Pleroma.DataCase, async: true
alias Pleroma.Chat
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
@ -35,7 +34,6 @@ defmodule Pleroma.ChatTest do
{:ok, chat_two} = Chat.bump_or_create(user.id, other_user.ap_id)
assert chat.id == chat_two.id
assert chat_two.unread == 2
end
test "it returns a chat for a user and recipient if it already exists" do
@ -48,15 +46,13 @@ defmodule Pleroma.ChatTest do
assert chat.id == chat_two.id
end
test "a returning chat will have an updated `update_at` field and an incremented unread count" do
test "a returning chat will have an updated `update_at` field" do
user = insert(:user)
other_user = insert(:user)
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
assert chat.unread == 1
:timer.sleep(1500)
{:ok, chat_two} = Chat.bump_or_create(user.id, other_user.ap_id)
assert chat_two.unread == 2
assert chat.id == chat_two.id
assert chat.updated_at != chat_two.updated_at