mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Apply syntax_tree formatting to app/*
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SpamRule::AutoSilence
|
||||
|
||||
attr_reader :group_message
|
||||
|
||||
def initialize(user, post = nil)
|
||||
@@ -10,9 +9,7 @@ class SpamRule::AutoSilence
|
||||
end
|
||||
|
||||
def perform
|
||||
I18n.with_locale(SiteSetting.default_locale) do
|
||||
silence_user if should_autosilence?
|
||||
end
|
||||
I18n.with_locale(SiteSetting.default_locale) { silence_user if should_autosilence? }
|
||||
end
|
||||
|
||||
def self.prevent_posting?(user)
|
||||
@@ -36,7 +33,7 @@ class SpamRule::AutoSilence
|
||||
user_id: @user.id,
|
||||
spam_type: PostActionType.types[:spam],
|
||||
pending: ReviewableScore.statuses[:pending],
|
||||
agreed: ReviewableScore.statuses[:agreed]
|
||||
agreed: ReviewableScore.statuses[:agreed],
|
||||
}
|
||||
|
||||
result = DB.query(<<~SQL, params)
|
||||
@@ -53,23 +50,30 @@ class SpamRule::AutoSilence
|
||||
end
|
||||
|
||||
def flagged_post_ids
|
||||
Post.where(user_id: @user.id)
|
||||
.where('spam_count > 0 OR off_topic_count > 0 OR inappropriate_count > 0')
|
||||
Post
|
||||
.where(user_id: @user.id)
|
||||
.where("spam_count > 0 OR off_topic_count > 0 OR inappropriate_count > 0")
|
||||
.pluck(:id)
|
||||
end
|
||||
|
||||
def silence_user
|
||||
Post.transaction do
|
||||
|
||||
silencer = UserSilencer.new(
|
||||
@user,
|
||||
Discourse.system_user,
|
||||
message: :too_many_spam_flags,
|
||||
post_id: @post&.id
|
||||
)
|
||||
silencer =
|
||||
UserSilencer.new(
|
||||
@user,
|
||||
Discourse.system_user,
|
||||
message: :too_many_spam_flags,
|
||||
post_id: @post&.id,
|
||||
)
|
||||
|
||||
if silencer.silence && SiteSetting.notify_mods_when_user_silenced
|
||||
@group_message = GroupMessage.create(Group[:moderators].name, :user_automatically_silenced, user: @user, limit_once_per: false)
|
||||
@group_message =
|
||||
GroupMessage.create(
|
||||
Group[:moderators].name,
|
||||
:user_automatically_silenced,
|
||||
user: @user,
|
||||
limit_once_per: false,
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SpamRule::FlagSockpuppets
|
||||
|
||||
def initialize(post)
|
||||
@post = post
|
||||
end
|
||||
@@ -21,23 +20,20 @@ class SpamRule::FlagSockpuppets
|
||||
return false if @post.try(:post_number) == 1
|
||||
return false if first_post.user.nil?
|
||||
|
||||
!first_post.user.staff? &&
|
||||
!@post.user.staff? &&
|
||||
!first_post.user.staged? &&
|
||||
!@post.user.staged? &&
|
||||
@post.user != first_post.user &&
|
||||
@post.user.ip_address == first_post.user.ip_address &&
|
||||
@post.user.new_user? &&
|
||||
!ScreenedIpAddress.is_allowed?(@post.user.ip_address)
|
||||
!first_post.user.staff? && !@post.user.staff? && !first_post.user.staged? &&
|
||||
!@post.user.staged? && @post.user != first_post.user &&
|
||||
@post.user.ip_address == first_post.user.ip_address && @post.user.new_user? &&
|
||||
!ScreenedIpAddress.is_allowed?(@post.user.ip_address)
|
||||
end
|
||||
|
||||
def flag_sockpuppet_users
|
||||
message = I18n.t(
|
||||
'flag_reason.sockpuppet',
|
||||
ip_address: @post.user.ip_address,
|
||||
base_path: Discourse.base_path,
|
||||
locale: SiteSetting.default_locale
|
||||
)
|
||||
message =
|
||||
I18n.t(
|
||||
"flag_reason.sockpuppet",
|
||||
ip_address: @post.user.ip_address,
|
||||
base_path: Discourse.base_path,
|
||||
locale: SiteSetting.default_locale,
|
||||
)
|
||||
|
||||
flag_post(@post, message)
|
||||
|
||||
@@ -55,5 +51,4 @@ class SpamRule::FlagSockpuppets
|
||||
def first_post
|
||||
@first_post ||= @post.topic.posts.by_post_number.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user