Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffc0183809 | ||
|
|
dcefd58240 | ||
|
|
6196a6d99a | ||
|
|
8ea412bc85 | ||
|
|
862ef37e7f | ||
|
|
9a1d5519ec | ||
|
|
e17f0ea753 | ||
|
|
f7580f864c | ||
|
|
85aeaf2aee | ||
|
|
e93af2681e | ||
|
|
cb2b75ca17 | ||
|
|
608592db0c | ||
|
|
ab1f803354 | ||
|
|
b81c722ac8 | ||
|
|
b40ad399f6 | ||
|
|
dcd18072b4 | ||
|
|
bda2d1d9a4 | ||
|
|
83231b9678 |
@@ -124,6 +124,10 @@ class Conversation < ApplicationRecord
|
||||
last_message_in_messaging_window?(messaging_window)
|
||||
end
|
||||
|
||||
def last_activity_at
|
||||
self[:last_activity_at] || created_at
|
||||
end
|
||||
|
||||
def last_incoming_message
|
||||
messages&.incoming&.last
|
||||
end
|
||||
|
||||
@@ -40,6 +40,7 @@ class Conversations::EventDataPresenter < SimpleDelegator
|
||||
{
|
||||
agent_last_seen_at: agent_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,
|
||||
created_at: created_at.to_i
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
shared: &shared
|
||||
version: '3.11.0'
|
||||
version: '3.11.1'
|
||||
|
||||
development:
|
||||
<<: *shared
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@chatwoot/chatwoot",
|
||||
"version": "3.11.0",
|
||||
"version": "3.11.1",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"eslint": "eslint app/**/*.{js,vue}",
|
||||
|
||||
@@ -525,6 +525,7 @@ RSpec.describe Conversation do
|
||||
id: conversation.display_id,
|
||||
messages: [],
|
||||
labels: [],
|
||||
last_activity_at: conversation.last_activity_at.to_i,
|
||||
inbox_id: conversation.inbox_id,
|
||||
status: conversation.status,
|
||||
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]
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user