feat: Add inbox webhook events (#8006)
- Add webhook events for inbox creation/updation. - Right now, the feature is added under a feature_flag. It is not available by default on all installations.
This commit is contained in:
@@ -77,6 +77,9 @@ class Inbox < ApplicationRecord
|
||||
|
||||
after_destroy :delete_round_robin_agents
|
||||
|
||||
after_create_commit :dispatch_create_event
|
||||
after_update_commit :dispatch_update_event
|
||||
|
||||
scope :order_by_name, -> { order('lower(name) ASC') }
|
||||
|
||||
def add_member(user_id)
|
||||
@@ -159,6 +162,18 @@ class Inbox < ApplicationRecord
|
||||
|
||||
private
|
||||
|
||||
def dispatch_create_event
|
||||
return if ENV['ENABLE_INBOX_EVENTS'].blank?
|
||||
|
||||
Rails.configuration.dispatcher.dispatch(INBOX_CREATED, Time.zone.now, inbox: self)
|
||||
end
|
||||
|
||||
def dispatch_update_event
|
||||
return if ENV['ENABLE_INBOX_EVENTS'].blank?
|
||||
|
||||
Rails.configuration.dispatcher.dispatch(INBOX_UPDATED, Time.zone.now, inbox: self, changed_attributes: previous_changes)
|
||||
end
|
||||
|
||||
def ensure_valid_max_assignment_limit
|
||||
# overridden in enterprise/app/models/enterprise/inbox.rb
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class Webhook < ApplicationRecord
|
||||
enum webhook_type: { account_type: 0, inbox_type: 1 }
|
||||
|
||||
ALLOWED_WEBHOOK_EVENTS = %w[conversation_status_changed conversation_updated conversation_created contact_created contact_updated
|
||||
message_created message_updated webwidget_triggered].freeze
|
||||
message_created message_updated webwidget_triggered inbox_created inbox_updated].freeze
|
||||
|
||||
private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user