chore: Fix for empty update case for messages (#8641)

We observed an issue in production where the external webhook for an API inbox was failing. This, in turn, calls message update to update message status to failed. This causes a loop because rails trigger after_update callbacks even for empty commits.

Ref: rails/rails#44500
This commit is contained in:
Sojan Jose
2024-01-05 13:10:26 -08:00
committed by GitHub
parent 2c7f93978e
commit dc4e13b300

View File

@@ -299,6 +299,10 @@ class Message < ApplicationRecord
end
def dispatch_update_event
# ref: https://github.com/rails/rails/issues/44500
# we want to skip the update event if the message is not updated
return if previous_changes.blank?
Rails.configuration.dispatcher.dispatch(MESSAGE_UPDATED, Time.zone.now, message: self, performed_by: Current.executed_by,
previous_changes: previous_changes)
end