mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
Add rubocop to our build. (#5004)
This commit is contained in:
@ -239,8 +239,8 @@ class PostCreator
|
||||
return unless post.reply_to_post_number.present?
|
||||
|
||||
reply_info = Post.where(topic_id: post.topic_id, post_number: post.reply_to_post_number)
|
||||
.select(:user_id, :post_type)
|
||||
.first
|
||||
.select(:user_id, :post_type)
|
||||
.first
|
||||
|
||||
if reply_info.present?
|
||||
post.reply_to_user_id ||= reply_info.user_id
|
||||
@ -316,11 +316,11 @@ class PostCreator
|
||||
|
||||
def handle_spam
|
||||
if @spam
|
||||
GroupMessage.create( Group[:moderators].name,
|
||||
GroupMessage.create(Group[:moderators].name,
|
||||
:spam_post_blocked,
|
||||
{ user: @user,
|
||||
limit_once_per: 24.hours,
|
||||
message_params: {domains: @post.linked_hosts.keys.join(', ')} } )
|
||||
user: @user,
|
||||
limit_once_per: 24.hours,
|
||||
message_params: { domains: @post.linked_hosts.keys.join(', ') })
|
||||
elsif @post && errors.blank? && !skip_validations?
|
||||
SpamRulesEnforcer.enforce!(@post)
|
||||
end
|
||||
@ -339,7 +339,7 @@ class PostCreator
|
||||
unless @topic.topic_allowed_users.where(user_id: @user.id).exists?
|
||||
unless @topic.topic_allowed_groups.where('group_id IN (
|
||||
SELECT group_id FROM group_users where user_id = ?
|
||||
)',@user.id).exists?
|
||||
)', @user.id).exists?
|
||||
@topic.topic_allowed_users.create!(user_id: @user.id)
|
||||
end
|
||||
end
|
||||
@ -363,11 +363,13 @@ class PostCreator
|
||||
def find_category_id
|
||||
@opts.delete(:category) if @opts[:archetype].present? && @opts[:archetype] == Archetype.private_message
|
||||
|
||||
category = if (@opts[:category].is_a? Integer) || (@opts[:category] =~ /^\d+$/)
|
||||
Category.find_by(id: @opts[:category])
|
||||
else
|
||||
Category.find_by(name_lower: @opts[:category].try(:downcase))
|
||||
end
|
||||
category =
|
||||
if (@opts[:category].is_a? Integer) || (@opts[:category] =~ /^\d+$/)
|
||||
Category.find_by(id: @opts[:category])
|
||||
else
|
||||
Category.find_by(name_lower: @opts[:category].try(:downcase))
|
||||
end
|
||||
|
||||
category&.id
|
||||
end
|
||||
|
||||
@ -491,7 +493,6 @@ class PostCreator
|
||||
last_read_post_number: @post.post_number,
|
||||
highest_seen_post_number: @post.post_number)
|
||||
|
||||
|
||||
# assume it took us 5 seconds of reading time to make a post
|
||||
PostTiming.record_timing(topic_id: @post.topic_id,
|
||||
user_id: @post.user_id,
|
||||
|
Reference in New Issue
Block a user