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:
Vishnu Narayanan
2024-01-10 11:21:48 +05:30
committed by GitHub
parent 5845881b08
commit d731c972ad
2 changed files with 63 additions and 0 deletions

View File

@@ -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