mirror of
https://github.com/discourse/discourse.git
synced 2024-11-21 08:34:17 -06:00
FEATURE: watch title for automatic tagging (#12782)
Previously watched words ignored topic titles when applying auto tagging rules. Also copy has been improved to reflect how the system behaves. The text hints that we are only watching first post now
This commit is contained in:
parent
3e6c39228d
commit
e4f1760bab
@ -63,7 +63,7 @@ module Jobs
|
|||||||
end
|
end
|
||||||
|
|
||||||
def auto_tag(post)
|
def 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_set
|
old_tags = post.topic.tags.pluck(:name).to_set
|
||||||
new_tags = old_tags.dup
|
new_tags = old_tags.dup
|
||||||
|
@ -46,7 +46,7 @@ class WordWatcher
|
|||||||
end
|
end
|
||||||
Regexp.new(regexp, Regexp::IGNORECASE)
|
Regexp.new(regexp, Regexp::IGNORECASE)
|
||||||
end
|
end
|
||||||
rescue RegexpError => e
|
rescue RegexpError
|
||||||
raise if raise_errors
|
raise if raise_errors
|
||||||
nil # Admin will be alerted via admin_dashboard_data.rb
|
nil # Admin will be alerted via admin_dashboard_data.rb
|
||||||
end
|
end
|
||||||
|
@ -4684,16 +4684,16 @@ en:
|
|||||||
require_approval: "Require Approval"
|
require_approval: "Require Approval"
|
||||||
flag: "Flag"
|
flag: "Flag"
|
||||||
replace: "Replace"
|
replace: "Replace"
|
||||||
tag: "Auto-tag"
|
tag: "Tag"
|
||||||
action_descriptions:
|
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."
|
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."
|
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."
|
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."
|
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"
|
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:
|
form:
|
||||||
label: "New Word"
|
label: "Has the word"
|
||||||
placeholder: "full word or * as wildcard"
|
placeholder: "full word or * as wildcard"
|
||||||
placeholder_regexp: "regular expression"
|
placeholder_regexp: "regular expression"
|
||||||
replacement_label: "Replacement"
|
replacement_label: "Replacement"
|
||||||
|
@ -106,6 +106,12 @@ describe Jobs::ProcessPost do
|
|||||||
post = Fabricate(:post, raw: "Greetings?", cooked: "")
|
post = Fabricate(:post, raw: "Greetings?", cooked: "")
|
||||||
Jobs::ProcessPost.new.execute(post_id: post.id)
|
Jobs::ProcessPost.new.execute(post_id: post.id)
|
||||||
expect(post.topic.reload.tags.pluck(:name)).to contain_exactly("hello", "world")
|
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")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "automatically tags first posts (regex)" do
|
it "automatically tags first posts (regex)" do
|
||||||
|
Loading…
Reference in New Issue
Block a user