Merge branch 'hotfix/3.11.1'

This commit is contained in:
Pranav
2024-08-12 15:11:19 +05:30
5 changed files with 43 additions and 2 deletions

View File

@@ -124,6 +124,10 @@ class Conversation < ApplicationRecord
last_message_in_messaging_window?(messaging_window) last_message_in_messaging_window?(messaging_window)
end end
def last_activity_at
self[:last_activity_at] || created_at
end
def last_incoming_message def last_incoming_message
messages&.incoming&.last messages&.incoming&.last
end end

View File

@@ -40,6 +40,7 @@ class Conversations::EventDataPresenter < SimpleDelegator
{ {
agent_last_seen_at: agent_last_seen_at.to_i, agent_last_seen_at: agent_last_seen_at.to_i,
contact_last_seen_at: contact_last_seen_at.to_i, contact_last_seen_at: contact_last_seen_at.to_i,
last_activity_at: last_activity_at.to_i,
timestamp: last_activity_at.to_i, timestamp: last_activity_at.to_i,
created_at: created_at.to_i created_at: created_at.to_i
} }

View File

@@ -1,5 +1,5 @@
shared: &shared shared: &shared
version: '3.11.0' version: '3.11.1'
development: development:
<<: *shared <<: *shared

View File

@@ -1,6 +1,6 @@
{ {
"name": "@chatwoot/chatwoot", "name": "@chatwoot/chatwoot",
"version": "3.11.0", "version": "3.11.1",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"eslint": "eslint app/**/*.{js,vue}", "eslint": "eslint app/**/*.{js,vue}",

View File

@@ -525,6 +525,7 @@ RSpec.describe Conversation do
id: conversation.display_id, id: conversation.display_id,
messages: [], messages: [],
labels: [], labels: [],
last_activity_at: conversation.last_activity_at.to_i,
inbox_id: conversation.inbox_id, inbox_id: conversation.inbox_id,
status: conversation.status, status: conversation.status,
contact_inbox: conversation.contact_inbox, contact_inbox: conversation.contact_inbox,
@@ -881,4 +882,39 @@ RSpec.describe Conversation do
expect(conversation.cached_label_list_array).to eq %w[customer-support enterprise paid-customer] expect(conversation.cached_label_list_array).to eq %w[customer-support enterprise paid-customer]
end end
end end
describe '#last_activity_at' do
let(:conversation) { create(:conversation) }
let(:message_params) do
{
conversation: conversation,
account: conversation.account,
inbox: conversation.inbox,
sender: conversation.assignee
}
end
context 'when a new conversation is created' do
it 'sets last_activity_at to the created_at time' do
expect(conversation.last_activity_at).to eq(conversation.created_at)
end
end
context 'when a new message is added' do
it 'updates the last_activity_at to the new message\'s created_at time' do
message = create(:message, created_at: 1.hour.from_now, **message_params)
conversation.reload
expect(conversation.last_activity_at).to be_within(1.second).of(message.created_at)
end
end
context 'when multiple messages are added' do
it 'sets last_activity_at to the most recent message\'s created_at time' do
create(:message, created_at: 2.hours.ago, **message_params)
latest_message = create(:message, created_at: 1.hour.from_now, **message_params)
conversation.reload
expect(conversation.last_activity_at).to be_within(1.second).of(latest_message.created_at)
end
end
end
end end