Auto-promote DanbooruBot to Mod. Auto-create DanbooruBot if it doesn't exist.
This commit is contained in:
@@ -86,7 +86,7 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def create_automated(params)
|
||||
dmail = Dmail.new(from: Danbooru.config.system_user, **params)
|
||||
dmail = Dmail.new(from: User.system, **params)
|
||||
dmail.owner = dmail.to
|
||||
dmail.save
|
||||
dmail
|
||||
@@ -234,7 +234,7 @@ class Dmail < ApplicationRecord
|
||||
end
|
||||
|
||||
def is_automated?
|
||||
from == Danbooru.config.system_user
|
||||
from == User.system
|
||||
end
|
||||
|
||||
def filtered?
|
||||
|
||||
@@ -316,7 +316,7 @@ class User < ApplicationRecord
|
||||
|
||||
module ClassMethods
|
||||
def system
|
||||
Danbooru.config.system_user
|
||||
User.find_by!(name: Danbooru.config.system_user)
|
||||
end
|
||||
|
||||
def level_hash
|
||||
@@ -366,7 +366,7 @@ class User < ApplicationRecord
|
||||
def promote_to_admin_if_first_user
|
||||
return if Rails.env.test?
|
||||
|
||||
if User.count == 0
|
||||
if User.admins.count == 0
|
||||
self.level = Levels::ADMIN
|
||||
self.can_approve_posts = true
|
||||
self.can_upload_free = true
|
||||
|
||||
Reference in New Issue
Block a user