FEATURE: Change tags sent in topic_tags_changed trigger in automation plugin (#28318)

* FEATURE: Change tags sent in topic_tags_changed trigger in discourse_automation

Before, it was sending the old tags and the current tags in topic.
Now, it sends the removed tags and the added tags in the topic.

* DEV: update `missing_tags` to be `removed_tags`

* DEV: add spacing for better readability
This commit is contained in:
Gabriel Grubba
2024-08-12 14:05:16 -03:00
committed by GitHub
parent 79f871b558
commit 157c8e660a
2 changed files with 46 additions and 4 deletions

View File

@ -206,12 +206,16 @@ module DiscourseAutomation
next if !watching_categories["value"].include?(topic.category_id)
end
removed_tags = old_tag_names - new_tag_names
added_tags = new_tag_names - old_tag_names
watching_tags = automation.trigger_field("watching_tags")
if watching_tags["value"]
should_skip = false
watching_tags["value"].each do |tag|
should_skip = true if !old_tag_names.empty? && !old_tag_names.include?(tag)
should_skip = true if !new_tag_names.empty? && !new_tag_names.include?(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
end
@ -219,8 +223,8 @@ module DiscourseAutomation
automation.trigger!(
"kind" => name,
"topic" => topic,
"removed_tags" => old_tag_names,
"added_tags" => new_tag_names,
"removed_tags" => removed_tags,
"added_tags" => added_tags,
)
end
end