FIX: TopicTagsChanged trigger not working with multiple tags (#29961)

* FIX: `TopicTagsChanged` trigger not working with multiple tags

The check for when had multiple tags was being exclusive, you had to have all tags to trigger the automation, now it's inclusive, you can trigger the automation if you have any of the tags.

* DEV: add specs for when having multiple categories

* DEV: changed to use unions and intersections for tags

added more tests to check for multiple tags
This commit is contained in:
Gabriel Grubba
2024-11-27 14:16:29 -03:00
committed by GitHub
parent fac6147039
commit 43414abf83
2 changed files with 111 additions and 6 deletions

View File

@ -239,12 +239,8 @@ module DiscourseAutomation
watching_tags = automation.trigger_field("watching_tags")
if watching_tags["value"]
should_skip = false
watching_tags["value"].each do |tag|
should_skip = true if !removed_tags.empty? && !removed_tags.include?(tag)
should_skip = true if !added_tags.empty? && !added_tags.include?(tag)
end
next if should_skip
changed_tags = (removed_tags | added_tags)
next if (changed_tags & watching_tags["value"]).empty?
end
automation.trigger!(