mirror of
https://github.com/discourse/discourse.git
synced 2024-12-18 15:43:47 +08:00
efd6394cd8
The server cannot always determine when a watched word regular expression is invalid and this commit implements the check on the client side.
18 lines
334 B
Ruby
18 lines
334 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id, :word, :regexp, :replacement, :action
|
|
|
|
def regexp
|
|
WordWatcher.word_to_regexp(word)
|
|
end
|
|
|
|
def action
|
|
WatchedWord.actions[object.action]
|
|
end
|
|
|
|
def include_replacement?
|
|
WatchedWord.has_replacement?(action)
|
|
end
|
|
end
|