remove unread_conversation_count from User
This commit is contained in:
parent
e0eb90f62a
commit
0d5088c2b8
9 changed files with 92 additions and 94 deletions
|
|
@ -37,9 +37,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
[%{read: true}] = Participation.for_user(user)
|
||||
[%{read: false} = participation] = Participation.for_user(other_user)
|
||||
|
||||
assert User.get_cached_by_id(user.id).unread_conversation_count == 0
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(user) == 0
|
||||
assert Participation.unread_count(other_user) == 1
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(other_user, %{
|
||||
|
|
@ -54,8 +53,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
[%{read: false}] = Participation.for_user(user)
|
||||
[%{read: true}] = Participation.for_user(other_user)
|
||||
|
||||
assert User.get_cached_by_id(user.id).unread_conversation_count == 1
|
||||
assert User.get_cached_by_id(other_user.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(user) == 1
|
||||
assert Participation.unread_count(other_user) == 0
|
||||
end
|
||||
|
||||
test "for a new conversation, it sets the recipents of the participation" do
|
||||
|
|
@ -264,7 +263,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
assert [%{read: false}, %{read: false}, %{read: false}, %{read: false}] =
|
||||
Participation.for_user(blocker)
|
||||
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 4
|
||||
assert Participation.unread_count(blocker) == 4
|
||||
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
|
||||
|
|
@ -272,15 +271,15 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
assert [%{read: true}, %{read: true}, %{read: true}, %{read: false}] =
|
||||
Participation.for_user(blocker)
|
||||
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocker) == 1
|
||||
|
||||
# The conversation is not marked as read for the blocked user
|
||||
assert [_, _, %{read: false}] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocker) == 1
|
||||
|
||||
# The conversation is not marked as read for the third user
|
||||
assert [%{read: false}, _, _] = Participation.for_user(third_user)
|
||||
assert User.get_cached_by_id(third_user.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(third_user) == 1
|
||||
end
|
||||
|
||||
test "the new conversation with the blocked user is not marked as unread " do
|
||||
|
|
@ -298,7 +297,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
# When the blocked user is a recipient
|
||||
{:ok, _direct2} =
|
||||
|
|
@ -308,10 +307,10 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}, %{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
assert [%{read: false}, _] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
assert Participation.unread_count(blocked) == 1
|
||||
end
|
||||
|
||||
test "the conversation with the blocked user is not marked as unread on a reply" do
|
||||
|
|
@ -327,8 +326,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
|
||||
{:ok, _user_relationship} = User.block(blocker, blocked)
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
assert [blocked_participation] = Participation.for_user(blocked)
|
||||
|
||||
# When it's a reply from the blocked user
|
||||
|
|
@ -340,8 +339,8 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
assert [third_user_participation] = Participation.for_user(third_user)
|
||||
|
||||
# When it's a reply from the third user
|
||||
|
|
@ -353,11 +352,12 @@ defmodule Pleroma.Conversation.ParticipationTest do
|
|||
})
|
||||
|
||||
assert [%{read: true}] = Participation.for_user(blocker)
|
||||
assert User.get_cached_by_id(blocker.id).unread_conversation_count == 0
|
||||
assert Participation.unread_count(blocker) == 0
|
||||
|
||||
# Marked as unread for the blocked user
|
||||
assert [%{read: false}] = Participation.for_user(blocked)
|
||||
assert User.get_cached_by_id(blocked.id).unread_conversation_count == 1
|
||||
|
||||
assert Participation.unread_count(blocked) == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue