diff options
author | feld <feld@feld.me> | 2019-10-17 20:05:01 +0000 |
---|---|---|
committer | feld <feld@feld.me> | 2019-10-17 20:05:01 +0000 |
commit | 6c82b6e3bf42f9897522c0f7ebd101dd01311a46 (patch) | |
tree | fd418b37d3d0ef4980f4f9b6d354e3724b946d56 /test/conversation | |
parent | 1bfdf57fc777abf210c823bed284f69c0e27ce6d (diff) | |
parent | 359dd1890e6afcf80584021eaa2421336614dd07 (diff) | |
download | pleroma-6c82b6e3bf42f9897522c0f7ebd101dd01311a46.tar.gz pleroma-6c82b6e3bf42f9897522c0f7ebd101dd01311a46.zip |
Merge branch 'mark-converstation-as-read-on-new-direct-message' into 'develop'
Mastodon API / Conversations: Mark the conversation as read for the author when they send a new direct message
See merge request pleroma/pleroma!1853
Diffstat (limited to 'test/conversation')
-rw-r--r-- | test/conversation/participation_test.exs | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs index f430bdf75..a5af0d1b2 100644 --- a/test/conversation/participation_test.exs +++ b/test/conversation/participation_test.exs @@ -23,6 +23,39 @@ defmodule Pleroma.Conversation.ParticipationTest do assert %Pleroma.Conversation{} = participation.conversation end + test "for a new conversation or a reply, it doesn't mark the author's participation as unread" do + user = insert(:user) + other_user = insert(:user) + + {:ok, _} = + CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"}) + + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) + + [%{read: true}] = Participation.for_user(user) + [%{read: false} = participation] = Participation.for_user(other_user) + + assert User.get_cached_by_id(user.id).info.unread_conversation_count == 0 + assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 1 + + {:ok, _} = + CommonAPI.post(other_user, %{ + "status" => "Hey @#{user.nickname}.", + "visibility" => "direct", + "in_reply_to_conversation_id" => participation.id + }) + + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) + + [%{read: false}] = Participation.for_user(user) + [%{read: true}] = Participation.for_user(other_user) + + assert User.get_cached_by_id(user.id).info.unread_conversation_count == 1 + assert User.get_cached_by_id(other_user.id).info.unread_conversation_count == 0 + end + test "for a new conversation, it sets the recipents of the participation" do user = insert(:user) other_user = insert(:user) @@ -32,7 +65,7 @@ defmodule Pleroma.Conversation.ParticipationTest do CommonAPI.post(user, %{"status" => "Hey @#{other_user.nickname}.", "visibility" => "direct"}) user = User.get_cached_by_id(user.id) - other_user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) [participation] = Participation.for_user(user) participation = Pleroma.Repo.preload(participation, :recipients) |