2020-01-09 07:36:40 +00:00
|
|
|
class Conversations::EventDataPresenter < SimpleDelegator
|
|
|
|
def push_data
|
|
|
|
{
|
2020-03-05 20:17:37 +00:00
|
|
|
additional_attributes: additional_attributes,
|
2020-07-25 17:24:45 +00:00
|
|
|
can_reply: can_reply?,
|
|
|
|
channel: inbox.try(:channel_type),
|
2021-09-29 14:03:51 +00:00
|
|
|
contact_inbox: contact_inbox,
|
2020-07-04 14:16:17 +00:00
|
|
|
id: display_id,
|
2020-01-09 07:36:40 +00:00
|
|
|
inbox_id: inbox_id,
|
|
|
|
messages: push_messages,
|
|
|
|
meta: push_meta,
|
2020-02-26 15:45:01 +00:00
|
|
|
status: status,
|
2022-02-03 04:35:56 +00:00
|
|
|
custom_attributes: custom_attributes,
|
2021-09-29 14:03:51 +00:00
|
|
|
snoozed_until: snoozed_until,
|
2020-01-09 07:36:40 +00:00
|
|
|
unread_count: unread_incoming_messages.count,
|
|
|
|
**push_timestamps
|
|
|
|
}
|
|
|
|
end
|
2019-10-12 18:08:41 +00:00
|
|
|
|
2020-01-09 07:36:40 +00:00
|
|
|
private
|
2019-10-12 18:08:41 +00:00
|
|
|
|
2020-01-09 07:36:40 +00:00
|
|
|
def push_messages
|
|
|
|
[messages.chat.last&.push_event_data].compact
|
|
|
|
end
|
2019-10-12 18:08:41 +00:00
|
|
|
|
2020-01-09 07:36:40 +00:00
|
|
|
def push_meta
|
2021-11-22 18:02:17 +00:00
|
|
|
{
|
|
|
|
sender: contact.push_event_data,
|
|
|
|
assignee: assignee&.push_event_data,
|
2022-08-12 08:10:28 +00:00
|
|
|
team: team&.push_event_data,
|
2021-11-22 18:02:17 +00:00
|
|
|
hmac_verified: contact_inbox&.hmac_verified
|
|
|
|
}
|
2020-01-09 07:36:40 +00:00
|
|
|
end
|
2019-10-12 18:08:41 +00:00
|
|
|
|
2020-01-09 07:36:40 +00:00
|
|
|
def push_timestamps
|
|
|
|
{
|
|
|
|
agent_last_seen_at: agent_last_seen_at.to_i,
|
2020-09-10 13:49:15 +00:00
|
|
|
contact_last_seen_at: contact_last_seen_at.to_i,
|
2020-10-05 17:22:43 +00:00
|
|
|
timestamp: last_activity_at.to_i
|
2020-01-09 07:36:40 +00:00
|
|
|
}
|
2019-10-12 18:08:41 +00:00
|
|
|
end
|
|
|
|
end
|