fix: skip auditlogs for whatsapp template sync (#8579)
Skips audit logs for whatsapp_template sync Fixes: https://linear.app/chatwoot/issue/CW-2641/skip-whatsapp-template-updates-from-audit-logs
This commit is contained in:
@@ -21,6 +21,9 @@ module Enterprise::Channelable
|
||||
|
||||
return if audited_changes.blank?
|
||||
|
||||
# skip audit log creation if the only change is whatsapp channel template update
|
||||
return if messaging_template_updates?(audited_changes)
|
||||
|
||||
Enterprise::AuditLog.create(
|
||||
auditable_id: auditable_id,
|
||||
auditable_type: auditable_type,
|
||||
@@ -30,5 +33,13 @@ module Enterprise::Channelable
|
||||
audited_changes: audited_changes
|
||||
)
|
||||
end
|
||||
|
||||
def messaging_template_updates?(changes)
|
||||
# if there is more than one key, return false
|
||||
return false unless changes.keys.length == 1
|
||||
|
||||
# if the only key is message_templates_last_updated, return true
|
||||
changes.key?('message_templates_last_updated')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user