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

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

diff --git a/app/jobs/scheduled/pending_users_reminder.rb b/app/jobs/scheduled/pending_users_reminder.rb
index 88c2fa4..85bedc6 100644
--- a/app/jobs/scheduled/pending_users_reminder.rb
+++ b/app/jobs/scheduled/pending_users_reminder.rb
@@ -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)
diff --git a/app/models/user.rb b/app/models/user.rb
index 97c8440..d47cc92 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
diff --git a/app/services/post_alerter.rb b/app/services/post_alerter.rb
index 632029f..454f981c 100644
--- a/app/services/post_alerter.rb
+++ b/app/services/post_alerter.rb
@@ -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]
diff --git a/lib/post_creator.rb b/lib/post_creator.rb
index 6d88d1a..77cc5d0 100644
--- a/lib/post_creator.rb
+++ b/lib/post_creator.rb
@@ -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)

GitHub sha: 32bae48f

2 Likes