mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: Make autotag watched words case insensitive (#13043)
* FIX: Hide tag watched words if tagging is disabled These 'autotag' words were shown even if tagging was disabled. * FIX: Make autotag watched words case insensitive This commit also fixes the bug when no tag was applied if no other tag was already present.
This commit is contained in:
@ -169,23 +169,23 @@ class TopicCreator
|
||||
end
|
||||
|
||||
def setup_tags(topic)
|
||||
return if @opts[:tags].blank?
|
||||
|
||||
valid_tags = DiscourseTagging.tag_topic_by_names(topic, @guardian, @opts[:tags])
|
||||
unless valid_tags
|
||||
topic.errors.add(:base, :unable_to_tag)
|
||||
rollback_from_errors!(topic)
|
||||
end
|
||||
|
||||
guardian = Guardian.new(Discourse.system_user)
|
||||
word_watcher = WordWatcher.new("#{@opts[:title]} #{@opts[:raw]}")
|
||||
word_watcher_tags = topic.tags.map(&:name)
|
||||
WordWatcher.words_for_action(:tag).each do |word, tags|
|
||||
if word_watcher.matches?(word)
|
||||
word_watcher_tags += tags.split(",")
|
||||
if @opts[:tags].present?
|
||||
valid_tags = DiscourseTagging.tag_topic_by_names(topic, @guardian, @opts[:tags])
|
||||
unless valid_tags
|
||||
topic.errors.add(:base, :unable_to_tag)
|
||||
rollback_from_errors!(topic)
|
||||
end
|
||||
end
|
||||
DiscourseTagging.tag_topic_by_names(topic, guardian, word_watcher_tags)
|
||||
|
||||
watched_words = WordWatcher.words_for_action(:tag)
|
||||
if watched_words.present?
|
||||
word_watcher = WordWatcher.new("#{@opts[:title]} #{@opts[:raw]}")
|
||||
word_watcher_tags = topic.tags.map(&:name)
|
||||
watched_words.each do |word, tags|
|
||||
word_watcher_tags += tags.split(",") if word_watcher.word_matches?(word)
|
||||
end
|
||||
DiscourseTagging.tag_topic_by_names(topic, Discourse.system_user.guardian, word_watcher_tags)
|
||||
end
|
||||
end
|
||||
|
||||
def setup_auto_close_time(topic)
|
||||
|
Reference in New Issue
Block a user