mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	fix: Automation loop on conversation_update (#4071)
This commit is contained in:
		| @@ -183,6 +183,9 @@ class Conversation < ApplicationRecord | ||||
|   end | ||||
|  | ||||
|   def notify_conversation_updation | ||||
|     return unless previous_changes.keys.present? && (previous_changes.keys & %w[team_id assignee_id status snoozed_until | ||||
|                                                                                 custom_attributes]).present? | ||||
|  | ||||
|     dispatcher_dispatch(CONVERSATION_UPDATED) | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -90,6 +90,20 @@ RSpec.describe Conversation, type: :model do | ||||
|         .with(described_class::CONVERSATION_READ, kind_of(Time), conversation: conversation, notifiable_assignee_change: true) | ||||
|       expect(Rails.configuration.dispatcher).to have_received(:dispatch) | ||||
|         .with(described_class::ASSIGNEE_CHANGED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true) | ||||
|       expect(Rails.configuration.dispatcher).to have_received(:dispatch) | ||||
|         .with(described_class::CONVERSATION_UPDATED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true) | ||||
|     end | ||||
|  | ||||
|     it 'will not run conversation_updated event for empty updates' do | ||||
|       conversation.save! | ||||
|       expect(Rails.configuration.dispatcher).not_to have_received(:dispatch) | ||||
|         .with(described_class::CONVERSATION_UPDATED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true) | ||||
|     end | ||||
|  | ||||
|     it 'will not run conversation_updated event for non whitelisted keys' do | ||||
|       conversation.update(updated_at: DateTime.now.utc) | ||||
|       expect(Rails.configuration.dispatcher).not_to have_received(:dispatch) | ||||
|         .with(described_class::CONVERSATION_UPDATED, kind_of(Time), conversation: conversation, notifiable_assignee_change: true) | ||||
|     end | ||||
|  | ||||
|     it 'creates conversation activities' do | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Sojan Jose
					Sojan Jose