chore: Remove account.destroy listener (#1530)
This commit is contained in:
@@ -15,7 +15,6 @@ class AccountBuilder
|
||||
end
|
||||
[@user, @account]
|
||||
rescue StandardError => e
|
||||
@account&.destroy
|
||||
puts e.inspect
|
||||
raise e
|
||||
end
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
class InstallationWebhookListener < BaseListener
|
||||
def account_created(event)
|
||||
payload = event.data[:account].webhook_data.merge(event: __method__.to_s)
|
||||
deliver_webhook_payloads(payload)
|
||||
end
|
||||
|
||||
def account_destroyed(event)
|
||||
payload = event.data[:account].webhook_data.merge(event: __method__.to_s)
|
||||
payload = account(event).webhook_data.merge(
|
||||
event: __method__.to_s,
|
||||
users: users(event)
|
||||
)
|
||||
deliver_webhook_payloads(payload)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def account(event)
|
||||
event.data[:account]
|
||||
end
|
||||
|
||||
def users(event)
|
||||
account(event).administrators.map(&:webhook_data)
|
||||
end
|
||||
|
||||
def deliver_webhook_payloads(payload)
|
||||
# Deliver the installation event
|
||||
webhook_url = InstallationConfig.find_by(name: 'INSTALLATION_EVENTS_WEBHOOK_URL')&.value
|
||||
|
||||
@@ -60,7 +60,6 @@ class Account < ApplicationRecord
|
||||
enum locale: LANGUAGES_CONFIG.map { |key, val| [val[:iso_639_1_code], key] }.to_h
|
||||
|
||||
after_create_commit :notify_creation
|
||||
after_destroy :notify_deletion
|
||||
|
||||
def agents
|
||||
users.where(account_users: { role: :agent })
|
||||
@@ -92,8 +91,4 @@ class Account < ApplicationRecord
|
||||
def notify_creation
|
||||
Rails.configuration.dispatcher.dispatch(ACCOUNT_CREATED, Time.zone.now, account: self)
|
||||
end
|
||||
|
||||
def notify_deletion
|
||||
Rails.configuration.dispatcher.dispatch(ACCOUNT_DESTROYED, Time.zone.now, account: self)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user