Chatwoot/app/services/message_templates/template/out_of_office.rb
Adam Zysko 65ed4c78a4
feat: Business hours
Data models and APIs for business hours

ref: #234
2020-11-01 00:14:33 +05:30

28 lines
630 B
Ruby

class MessageTemplates::Template::OutOfOffice
pattr_initialize [:conversation!]
def perform
ActiveRecord::Base.transaction do
conversation.messages.create!(out_of_office_message_params)
end
rescue StandardError => e
Raven.capture_exception(e)
true
end
private
delegate :contact, :account, to: :conversation
delegate :inbox, to: :message
def out_of_office_message_params
content = @conversation.inbox&.out_of_office_message
{
account_id: @conversation.account_id,
inbox_id: @conversation.inbox_id,
message_type: :template,
content: content
}
end
end