Feature: Inbox greeting message (#927)

Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
Sojan Jose
2020-06-09 23:54:35 +05:30
committed by GitHub
parent 8b022311c0
commit 432dad203b
48 changed files with 262 additions and 120 deletions

View File

@@ -7,6 +7,8 @@
# id :integer not null, primary key
# channel_type :string
# enable_auto_assignment :boolean default(TRUE)
# greeting_enabled :boolean default(FALSE)
# greeting_message :string
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null

View File

@@ -71,11 +71,9 @@ class Message < ApplicationRecord
has_many :attachments, dependent: :destroy, autosave: true, before_add: :validate_attachments_limit
after_create :reopen_conversation,
:execute_message_template_hooks,
:notify_via_mail
# we need to wait for the active storage attachments to be available
after_create_commit :dispatch_create_events, :send_reply
after_create_commit :execute_after_create_commit_callbacks
after_update :dispatch_update_event
@@ -117,6 +115,14 @@ class Message < ApplicationRecord
private
def execute_after_create_commit_callbacks
# rails issue with order of active record callbacks being executed
# https://github.com/rails/rails/issues/20911
dispatch_create_events
send_reply
execute_message_template_hooks
end
def dispatch_create_events
Rails.configuration.dispatcher.dispatch(MESSAGE_CREATED, Time.zone.now, message: self)