mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
fix intermittent failing tests, some watched word refactoring
This commit is contained in:
@@ -273,12 +273,6 @@ class PostRevisor
|
||||
@post.word_count = @fields[:raw].scan(/[[:word:]]+/).size if @fields.has_key?(:raw)
|
||||
@post.self_edits += 1 if self_edit?
|
||||
|
||||
if !@post.acting_user.staff? && !@post.acting_user.staged && WordWatcher.new(@post.raw).should_block?
|
||||
@post.errors[:base] << I18n.t('contains_blocked_words')
|
||||
@post_successfully_saved = false
|
||||
return
|
||||
end
|
||||
|
||||
remove_flags_and_unhide_post
|
||||
|
||||
@post.extract_quoted_post_numbers
|
||||
|
||||
@@ -33,6 +33,7 @@ class Validators::PostValidator < ActiveModel::Validator
|
||||
return if options[:skip_post_body] || post.topic&.pm_with_non_human_user?
|
||||
stripped_length(post)
|
||||
raw_quality(post)
|
||||
watched_words(post)
|
||||
end
|
||||
|
||||
def stripped_length(post)
|
||||
@@ -55,6 +56,12 @@ class Validators::PostValidator < ActiveModel::Validator
|
||||
post.errors.add(:raw, I18n.t(:is_invalid)) unless sentinel.valid?
|
||||
end
|
||||
|
||||
def watched_words(post)
|
||||
if !post.acting_user&.staff? && !post.acting_user&.staged && WordWatcher.new(post.raw).should_block?
|
||||
post.errors[:base] << I18n.t('contains_blocked_words')
|
||||
end
|
||||
end
|
||||
|
||||
# Ensure maximum amount of mentions in a post
|
||||
def max_mention_validator(post)
|
||||
return if post.acting_user.try(:staff?)
|
||||
|
||||
Reference in New Issue
Block a user