feat: Add webhook events for contact created, updated (#6415)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Shubham Kumar
2023-02-14 02:58:27 +05:30
committed by GitHub
parent ba69f4cd35
commit 29025759d6
13 changed files with 113 additions and 16 deletions

View File

@@ -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