Module: Livechat::Notifications
- Defined in:
- lib/livechat/notifications.rb
Overview
Fires the host hooks and the built-in emails after a message is saved. Email goes out only at the start of an unread stretch — the first message nobody has seen yet — so a burst of messages is one email, not ten. A failing hook must never break the chat, so hooks are rescued and logged.
Class Method Summary collapse
Class Method Details
.agent_message(message) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/livechat/notifications.rb', line 19 def () run_hook { Livechat.config..call() } return unless Livechat.config.emails_enabled? return if .conversation.visitor_email.blank? return unless first_unread?(, .conversation..from_agent) Mailer.new_agent_reply().deliver_later end |
.visitor_message(message) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/livechat/notifications.rb', line 10 def () run_hook { Livechat.config..call() } return unless Livechat.config.emails_enabled? return unless Livechat.config.agent_email_list.any? return unless first_unread?(, .conversation..from_visitor) Mailer.().deliver_later end |