Skip to content

Commit

Permalink
fix: Force account_id in message filters (#7705)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavrajs committed Aug 11, 2023
1 parent 1cac2e8 commit 1a06bfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/conversation.rb
Expand Up @@ -170,7 +170,7 @@ def unread_messages
end

def unread_incoming_messages
unread_messages.incoming.last(10)
unread_messages.where(account_id: account_id).incoming.last(10)
end

def push_event_data
Expand Down
Expand Up @@ -20,7 +20,10 @@ json.id conversation.display_id
if conversation.messages.first.blank?
json.messages []
else
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
json.messages [
conversation.messages.where(account_id: conversation.account_id)
.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)
]
end

json.account_id conversation.account_id
Expand All @@ -40,7 +43,7 @@ json.created_at conversation.created_at.to_i
json.timestamp conversation.last_activity_at.to_i
json.first_reply_created_at conversation.first_reply_created_at.to_i
json.unread_count conversation.unread_incoming_messages.count
json.last_non_activity_message conversation.messages.non_activity_messages.first.try(:push_event_data)
json.last_non_activity_message conversation.messages.where(account_id: conversation.account_id).non_activity_messages.first.try(:push_event_data)
json.last_activity_at conversation.last_activity_at.to_i
json.priority conversation.priority
json.waiting_since conversation.waiting_since.to_i.to_i

0 comments on commit 1a06bfd

Please sign in to comment.