feat: Add webhook events for contact created, updated (#6415)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -121,11 +121,16 @@ class Contact < ApplicationRecord
|
||||
|
||||
def webhook_data
|
||||
{
|
||||
id: id,
|
||||
name: name,
|
||||
account: account.webhook_data,
|
||||
additional_attributes: additional_attributes,
|
||||
avatar: avatar_url,
|
||||
type: 'contact',
|
||||
account: account.webhook_data
|
||||
custom_attributes: custom_attributes,
|
||||
email: email,
|
||||
id: id,
|
||||
identifier: identifier,
|
||||
name: name,
|
||||
phone_number: phone_number,
|
||||
thumbnail: avatar_url
|
||||
}
|
||||
end
|
||||
|
||||
@@ -180,7 +185,7 @@ class Contact < ApplicationRecord
|
||||
end
|
||||
|
||||
def dispatch_update_event
|
||||
Rails.configuration.dispatcher.dispatch(CONTACT_UPDATED, Time.zone.now, contact: self)
|
||||
Rails.configuration.dispatcher.dispatch(CONTACT_UPDATED, Time.zone.now, contact: self, changed_attributes: previous_changes)
|
||||
end
|
||||
|
||||
def dispatch_destroy_event
|
||||
|
||||
@@ -25,8 +25,8 @@ class Webhook < ApplicationRecord
|
||||
validate :validate_webhook_subscriptions
|
||||
enum webhook_type: { account_type: 0, inbox_type: 1 }
|
||||
|
||||
ALLOWED_WEBHOOK_EVENTS = %w[conversation_status_changed conversation_updated conversation_created message_created message_updated
|
||||
webwidget_triggered].freeze
|
||||
ALLOWED_WEBHOOK_EVENTS = %w[conversation_status_changed conversation_updated conversation_created contact_created contact_updated
|
||||
message_created message_updated webwidget_triggered].freeze
|
||||
|
||||
private
|
||||
|
||||
|
||||
Reference in New Issue
Block a user