A platform for community discussion. Free, open, simple.
FEATURE: watch title for automatic tagging (#12782)
Same4f1760babbb
diff --git a/app/jobs/regular/process_post.rb b/app/jobs/regular/process_post.rbindex 3db96c694b0..bddfc506ebc 100644--- a/app/jobs/regular/process_post.rb+++ b/app/jobs/regular/process_post.rb@@ -63,7 +63,7 @@ module Jobsenddef auto_tag(post)- word_watcher = WordWatcher.new(post.raw)+ word_watcher = WordWatcher.new("#{post.topic.title} #{post.raw}")old_tags = post.topic.tags.pluck(:name).to_setnew_tags = old_tags.dupdiff --git a/app/services/word_watcher.rb b/app/services/word_watcher.rbindex 3665c72102e..c37daea4da2 100644--- a/app/services/word_watcher.rb+++ b/app/services/word_watcher.rb@@ -46,7 +46,7 @@ class WordWatcherendRegexp.new(regexp, Regexp::IGNORECASE)end- rescue RegexpError => e+ rescue RegexpErrorraise if raise_errorsnil # Admin will be alerted via admin_dashboard_data.rbenddiff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 683958ad32b..efaadae43cd 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -4684,16 +4684,16 @@ en:require_approval: "Require Approval"flag: "Flag"replace: "Replace"- tag: "Auto-tag"+ tag: "Tag"action_descriptions:block: "Prevent posts containing these words from being posted. The user will see an error message when they try to submit their post."censor: "Allow posts containing these words, but replace them with characters that hide the censored words."require_approval: "Posts containing these words will require approval by staff before they can be seen."flag: "Allow posts containing these words, but flag them as inappropriate so moderators can review them."replace: "Replace words in posts with other words or links"- tag: "Automatically tag posts with these words"+ tag: "Automatically tag topics based on first post"form:- label: "New Word"+ label: "Has the word"placeholder: "full word or * as wildcard"placeholder_regexp: "regular expression"replacement_label: "Replacement"diff --git a/spec/jobs/process_post_spec.rb b/spec/jobs/process_post_spec.rbindex 09a847fe964..92920d72d1a 100644--- a/spec/jobs/process_post_spec.rb+++ b/spec/jobs/process_post_spec.rb@@ -106,6 +106,12 @@ describe Jobs::ProcessPost dopost = Fabricate(:post, raw: "Greetings?", cooked: "")Jobs::ProcessPost.new.execute(post_id: post.id)expect(post.topic.reload.tags.pluck(:name)).to contain_exactly("hello", "world")++ topic = Fabricate(:topic, title: "Greetings? People")+ post = Fabricate(:post, topic: topic, raw: "nothing yet", cooked: "")++ Jobs::ProcessPost.new.execute(post_id: post.id)+ expect(post.topic.reload.tags.pluck(:name)).to contain_exactly("hello", "world")endit "automatically tags first posts (regex)" do