feat: Add assignee last seen to conversations (#3069)
- Adds assignee last seen attribute to conversations
This commit is contained in:
@@ -69,6 +69,7 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
||||
|
||||
def update_last_seen
|
||||
@conversation.agent_last_seen_at = DateTime.now.utc
|
||||
@conversation.assignee_last_seen_at = DateTime.now.utc if assignee?
|
||||
@conversation.save!
|
||||
end
|
||||
|
||||
@@ -136,4 +137,8 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
||||
def conversation_finder
|
||||
@conversation_finder ||= ConversationFinder.new(current_user, params)
|
||||
end
|
||||
|
||||
def assignee?
|
||||
@conversation.assignee_id? && current_user == @conversation.assignee
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# id :integer not null, primary key
|
||||
# additional_attributes :jsonb
|
||||
# agent_last_seen_at :datetime
|
||||
# assignee_last_seen_at :datetime
|
||||
# contact_last_seen_at :datetime
|
||||
# custom_attributes :jsonb
|
||||
# identifier :string
|
||||
|
||||
@@ -4,6 +4,7 @@ json.meta do
|
||||
json.contact @conversation.contact.push_event_data
|
||||
json.assignee @conversation.assignee.push_event_data if @conversation.assignee.present?
|
||||
json.agent_last_seen_at @conversation.agent_last_seen_at
|
||||
json.assignee_last_seen_at @conversation.assignee_last_seen_at
|
||||
end
|
||||
|
||||
json.payload do
|
||||
|
||||
@@ -31,6 +31,7 @@ json.can_reply conversation.can_reply?
|
||||
json.timestamp conversation.last_activity_at.to_i
|
||||
json.contact_last_seen_at conversation.contact_last_seen_at.to_i
|
||||
json.agent_last_seen_at conversation.agent_last_seen_at.to_i
|
||||
json.assignee_last_seen_at conversation.assignee_last_seen_at.to_i
|
||||
json.unread_count conversation.unread_incoming_messages.count
|
||||
json.additional_attributes conversation.additional_attributes
|
||||
json.custom_attributes conversation.custom_attributes
|
||||
|
||||
Reference in New Issue
Block a user