FIX: ensures global notices are destroyed on post created (#28684)

Prior to this fix we could exit early if tags was `[]` as `tags && (tags & post.topic.tags.map(&:name)).empty?` would have returned true. This commit ensures it's not the case anymore and adds a test for it.

Co-Authored-By: Martin Brennan <mjrbrennan@gmail.com>
This commit is contained in:
Joffrey JAFFEUX
2024-09-02 21:17:10 +02:00
committed by GitHub
parent b771d3173f
commit 0a1432e1cc
3 changed files with 33 additions and 1 deletions

View File

@ -330,7 +330,7 @@ module DiscourseAutomation
next if categories && !categories.include?(post.topic.category_id)
tags = fields.dig("tags", "value")
next if tags && (tags & post.topic.tags.map(&:name)).empty?
next if tags&.any? && (tags & post.topic.tags.map(&:name)).empty?
DiscourseAutomation::UserGlobalNotice
.where(identifier: automation.id)