feat: Add support for labels in automations (#11658)

- Add support for using labels as an action event for automation
 - Fix duplicated conversation_updated event dispatch for labels
 

Fixes https://github.com/chatwoot/chatwoot/issues/8539 and multiple
issues around duplication related to label change events.
---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
This commit is contained in:
Vishnu Narayanan
2025-09-18 14:17:54 +05:30
committed by GitHub
parent 44dc9ba18e
commit 9527ff6269
13 changed files with 461 additions and 6 deletions

View File

@@ -60,6 +60,32 @@ RSpec.describe AutomationRule do
expect(rule.valid?).to be false
expect(rule.errors.messages[:conditions]).to eq(['Automation conditions should have query operator.'])
end
it 'allows labels as a valid condition attribute' do
params[:conditions] = [
{
attribute_key: 'labels',
filter_operator: 'equal_to',
values: ['bug'],
query_operator: nil
}
]
rule = FactoryBot.build(:automation_rule, params)
expect(rule.valid?).to be true
end
it 'validates label condition operators' do
params[:conditions] = [
{
attribute_key: 'labels',
filter_operator: 'is_present',
values: [],
query_operator: nil
}
]
rule = FactoryBot.build(:automation_rule, params)
expect(rule.valid?).to be true
end
end
describe 'reauthorizable' do

View File

@@ -136,7 +136,7 @@ RSpec.describe Conversation do
notifiable_assignee_change: false,
changed_attributes: changed_attributes,
performed_by: nil
).exactly(2).times
)
end
it 'runs after_update callbacks' do