fix: Limit the number of unread messages returned in the API (#1504)

This commit is contained in:
Pranav Raj S
2020-12-10 23:30:38 +05:30
committed by GitHub
parent 88c4b63eec
commit b6ca77158c
2 changed files with 4 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ json.id conversation.display_id
if conversation.unread_incoming_messages.count.zero?
json.messages [conversation.messages.includes([{ attachments: [{ file_attachment: [:blob] }] }]).last.try(:push_event_data)]
else
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).map(&:push_event_data)
json.messages conversation.unread_messages.includes([:user, { attachments: [{ file_attachment: [:blob] }] }]).last(10).map(&:push_event_data)
end
json.inbox_id conversation.inbox_id