Add watched words of type "replace" (#12020)

This commit includes other various improvements to watched words.

auto_silence_first_post_regex site setting was removed because it overlapped
with 'require approval' watched words.
This commit is contained in:
Bianca Nenciu
2021-02-25 14:00:58 +02:00
committed by GitHub
parent a9a93b15ec
commit 533800a87b
26 changed files with 384 additions and 154 deletions

View File

@@ -7,7 +7,8 @@ class WatchedWord < ActiveRecord::Base
block: 1,
censor: 2,
require_approval: 3,
flag: 4
flag: 4,
replace: 5
)
end
@@ -37,6 +38,7 @@ class WatchedWord < ActiveRecord::Base
def self.create_or_update_word(params)
new_word = normalize_word(params[:word])
w = WatchedWord.where("word ILIKE ?", new_word).first || WatchedWord.new(word: new_word)
w.replacement = params[:replacement] if params[:replacement]
w.action_key = params[:action_key] if params[:action_key]
w.action = params[:action] if params[:action]
w.save
@@ -57,11 +59,12 @@ end
#
# Table name: watched_words
#
# id :integer not null, primary key
# word :string not null
# action :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# id :integer not null, primary key
# word :string not null
# action :integer not null
# created_at :datetime not null
# updated_at :datetime not null
# replacement :string
#
# Indexes
#