FIX: Split link watched words from replace (#13196)

It was not clear that replace watched words can be used to replace text
with URLs. This introduces a new watched word type that makes it easier
to understand.
This commit is contained in:
Bianca Nenciu
2021-06-02 08:36:49 +03:00
committed by GitHub
parent eea9fead63
commit d9484db718
20 changed files with 186 additions and 62 deletions

View File

@@ -8,7 +8,7 @@ class WordWatcher
def self.words_for_action(action)
words = WatchedWord.where(action: WatchedWord.actions[action.to_sym]).limit(1000)
if action.to_sym == :replace || action.to_sym == :tag
if WatchedWord.has_replacement?(action.to_sym)
words.pluck(:word, :replacement).to_h
else
words.pluck(:word)
@@ -31,7 +31,7 @@ class WordWatcher
def self.word_matcher_regexp(action, raise_errors: false)
words = get_cached_words(action)
if words
if action.to_sym == :replace || action.to_sym == :tag
if WatchedWord.has_replacement?(action.to_sym)
words = words.keys
end
words = words.map do |w|