feat: Ability to delete a contact (#2984)
This change allows the administrator user to delete a contact and its related data like conversations, contact inboxes, and reports. Fixes #1929
This commit is contained in:
@@ -48,6 +48,7 @@ class Contact < ApplicationRecord
|
||||
before_validation :prepare_email_attribute
|
||||
after_create_commit :dispatch_create_event, :ip_lookup
|
||||
after_update_commit :dispatch_update_event
|
||||
after_destroy_commit :dispatch_destroy_event
|
||||
|
||||
def get_source_id(inbox_id)
|
||||
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
|
||||
@@ -73,7 +74,8 @@ class Contact < ApplicationRecord
|
||||
id: id,
|
||||
name: name,
|
||||
avatar: avatar_url,
|
||||
type: 'contact'
|
||||
type: 'contact',
|
||||
account: account.webhook_data
|
||||
}
|
||||
end
|
||||
|
||||
@@ -98,4 +100,8 @@ class Contact < ApplicationRecord
|
||||
def dispatch_update_event
|
||||
Rails.configuration.dispatcher.dispatch(CONTACT_UPDATED, Time.zone.now, contact: self)
|
||||
end
|
||||
|
||||
def dispatch_destroy_event
|
||||
Rails.configuration.dispatcher.dispatch(CONTACT_DELETED, Time.zone.now, contact: self)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user