Auto-promote DanbooruBot to Mod. Auto-create DanbooruBot if it doesn't exist.

This commit is contained in:
evazion
2017-12-15 14:51:24 -06:00
parent b48211cd4a
commit e2eb45a5a3
8 changed files with 21 additions and 9 deletions

View File

@@ -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?

View File

@@ -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