feat: Bulk delete for contacts (#12778)
Introduces a new bulk action `delete` for contacts ref: https://github.com/chatwoot/chatwoot/pull/12763 ## Screens <img width="1492" height="973" alt="Screenshot 2025-10-31 at 6 27 21 PM" src="https://github.com/user-attachments/assets/30dab1bb-2c2c-4168-9800-44e0eb5f8e3a" /> <img width="1492" height="985" alt="Screenshot 2025-10-31 at 6 27 32 PM" src="https://github.com/user-attachments/assets/5be610c4-b19e-4614-a164-103b22337382" />
This commit is contained in:
18
app/services/contacts/bulk_delete_service.rb
Normal file
18
app/services/contacts/bulk_delete_service.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class Contacts::BulkDeleteService
|
||||
def initialize(account:, contact_ids: [])
|
||||
@account = account
|
||||
@contact_ids = Array(contact_ids).compact
|
||||
end
|
||||
|
||||
def perform
|
||||
return if @contact_ids.blank?
|
||||
|
||||
contacts.find_each(&:destroy!)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contacts
|
||||
@account.contacts.where(id: @contact_ids)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user