chore: Refactor MarkMessagesAsReadJob based on conversation id and time stamp (#8217)

- Mark all messages as read by providing the conversation ID and timestamp.
- For Instagram, ensure all previous messages that weren't marked as failed are now marked as read. This is because the read events are only triggered for the most recent message and not for any previous ones.
This commit is contained in:
Muhsin Keloth
2023-10-28 03:51:39 +05:30
committed by GitHub
parent 61e03fa33a
commit 24fbab94c3
8 changed files with 36 additions and 24 deletions

View File

@@ -168,9 +168,12 @@ RSpec.describe '/api/v1/widget/conversations/toggle_typing', type: :request do
describe 'POST /api/v1/widget/conversations/update_last_seen' do
context 'with a conversation' do
it 'returns the correct conversation params' do
current_time = DateTime.now.utc
allow(DateTime).to receive(:now).and_return(current_time)
allow(Rails.configuration.dispatcher).to receive(:dispatch)
expect(conversation.contact_last_seen_at).to be_nil
expect(Conversations::MarkMessagesAsReadJob).to receive(:perform_later).with(conversation)
expect(Conversations::MarkMessagesAsReadJob).to receive(:perform_later).with(conversation.id, current_time)
post '/api/v1/widget/conversations/update_last_seen',
headers: { 'X-Auth-Token' => token },