Auto-promote DanbooruBot to Mod. Auto-create DanbooruBot if it doesn't exist.
This commit is contained in:
@@ -37,8 +37,10 @@ module Danbooru
|
||||
end
|
||||
|
||||
# System actions, such as sending automated dmails, will be performed with this account.
|
||||
# This account will be created automatically if it doesn't exist. It will
|
||||
# be promoted to Moderator if it isn't already a Moderator.
|
||||
def system_user
|
||||
User.find_by_name("DanbooruBot") || User.admins.first
|
||||
"DanbooruBot"
|
||||
end
|
||||
|
||||
def upload_feedback_topic
|
||||
|
||||
10
config/initializers/system_user.rb
Normal file
10
config/initializers/system_user.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require "securerandom"
|
||||
|
||||
system = User.find_or_create_by!(name: Danbooru.config.system_user) do |user|
|
||||
user.password = SecureRandom.base64(32)
|
||||
end
|
||||
|
||||
unless system.is_moderator?
|
||||
system.level = User::Levels::MODERATOR
|
||||
system.save
|
||||
end
|
||||
Reference in New Issue
Block a user