fix: capture user and ip details on Inbox delete (#7395)
Fixes: https://linear.app/chatwoot/issue/CW-1772/ip-address-and-user-details-are-missing-in-some-of-the-logs Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
18
enterprise/app/jobs/enterprise/delete_object_job.rb
Normal file
18
enterprise/app/jobs/enterprise/delete_object_job.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module Enterprise::DeleteObjectJob
|
||||
def process_post_deletion_tasks(object, user, ip)
|
||||
create_audit_entry(object, user, ip)
|
||||
end
|
||||
|
||||
def create_audit_entry(object, user, ip)
|
||||
return unless ['Inbox'].include?(object.class.to_s) && user.present?
|
||||
|
||||
Enterprise::AuditLog.create(
|
||||
auditable: object,
|
||||
audited_changes: object.attributes,
|
||||
action: 'destroy',
|
||||
user: user,
|
||||
associated: object.account,
|
||||
remote_address: ip
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -2,6 +2,6 @@ module Enterprise::Audit::Inbox
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
audited associated_with: :account
|
||||
audited associated_with: :account, on: [:create, :update]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user