mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:11:08 +08:00
DEV: Move autotag to topic creator (#12790)
This move was necessary to automatically tag the topic with the right tags from creation time. The process post job may be delayed for a short time.
This commit is contained in:
@ -176,6 +176,16 @@ class TopicCreator
|
||||
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(",")
|
||||
end
|
||||
end
|
||||
DiscourseTagging.tag_topic_by_names(topic, guardian, word_watcher_tags)
|
||||
end
|
||||
|
||||
def setup_auto_close_time(topic)
|
||||
|
Reference in New Issue
Block a user