Chatwoot/app/presenters/conversations/event_data_presenter.rb
Pranav Raj S 0f2d3418f9
fix: Add a check for 24 hour window before sending a message (#1084)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2020-07-25 22:54:45 +05:30

38 lines
826 B
Ruby

class Conversations::EventDataPresenter < SimpleDelegator
def lock_data
{ id: display_id, locked: locked? }
end
def push_data
{
additional_attributes: additional_attributes,
can_reply: can_reply?,
channel: inbox.try(:channel_type),
id: display_id,
inbox_id: inbox_id,
messages: push_messages,
meta: push_meta,
status: status,
unread_count: unread_incoming_messages.count,
**push_timestamps
}
end
private
def push_messages
[messages.chat.last&.push_event_data].compact
end
def push_meta
{ sender: contact.push_event_data, assignee: assignee }
end
def push_timestamps
{
agent_last_seen_at: agent_last_seen_at.to_i,
user_last_seen_at: user_last_seen_at.to_i,
timestamp: created_at.to_i
}
end
end