DEV: Use User#human? User#bot? (#7140)

This commit is contained in:
Dan Ungureanu 2019-03-12 01:58:14 +02:00 committed by Guo Xiang Tan
parent d1d9a4f128
commit 32bae48fd3
4 changed files with 8 additions and 5 deletions

View File

@ -20,7 +20,7 @@ module Jobs
if count > 0
target_usernames = Group[:moderators].users.map do |user|
next if user.id < 0
next if user.bot?
unseen_count = user.notifications.joins(:topic)
.where("notifications.id > ?", user.seen_notification_id)

View File

@ -294,6 +294,10 @@ class User < ActiveRecord::Base
self.id > 0
end
def bot?
!self.human?
end
def effective_locale
if SiteSetting.allow_user_locale && self.locale.present?
self.locale

View File

@ -13,7 +13,7 @@ class PostAlerter
def not_allowed?(user, post)
user.blank? ||
user.id < 0 ||
user.bot? ||
user.id == post.user_id
end
@ -279,8 +279,7 @@ class PostAlerter
DiscourseEvent.trigger(:before_create_notification, user, type, post, opts)
return if user.blank?
return if user.id < 0
return if user.blank? || user.bot?
is_liked = type == Notification.types[:liked]
return if is_liked && user.user_option.like_notification_frequency == UserOption.like_notification_frequency_type[:never]

View File

@ -514,7 +514,7 @@ class PostCreator
end
def create_post_notice
return if @user.id < 0 || @user.staged
return if @user.bot? || @user.staged
last_post_time = Post.where(user_id: @user.id)
.order(created_at: :desc)