mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user