+ 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
+