API: Don't mark conversations as read when fetching its messages

This commit is contained in:
Jonne Haß 2020-11-30 18:01:30 +01:00
parent d2acad1aed
commit a7ff52f366
2 changed files with 5 additions and 2 deletions

View file

@ -24,7 +24,6 @@ module Api
def index def index
conversation = conversation_service.find!(params.require(:conversation_id)) conversation = conversation_service.find!(params.require(:conversation_id))
conversation.set_read(current_user)
messages_page = index_pager(conversation.messages).response messages_page = index_pager(conversation.messages).response
messages_page[:data] = messages_page[:data].map {|x| message_json(x) } messages_page[:data] = messages_page[:data].map {|x| message_json(x) }
render_paged_api_response messages_page render_paged_api_response messages_page

View file

@ -116,6 +116,10 @@ describe Api::V1::MessagesController do
before do before do
post api_v1_conversations_path, params: @conversation post api_v1_conversations_path, params: @conversation
@conversation_guid = JSON.parse(response.body)["guid"] @conversation_guid = JSON.parse(response.body)["guid"]
Conversation.find_by(guid: @conversation_guid)
.conversation_visibilities
.where(person: auth.user.person)
.update(unread: true)
end end
context "retrieving messages" do context "retrieving messages" do
@ -132,7 +136,7 @@ describe Api::V1::MessagesController do
confirm_message_format(messages[0], "first message", auth.user) confirm_message_format(messages[0], "first message", auth.user)
conversation = get_conversation(@conversation_guid) conversation = get_conversation(@conversation_guid)
expect(conversation[:read]).to be_truthy expect(conversation[:read]).to be_falsy
end end
context "improper credentials" do context "improper credentials" do