mirror of
https://github.com/discourse/discourse.git
synced 2025-04-03 05:39:41 +08:00
FIX: ensure discobot always has a primary email
This commit is contained in:
parent
616a0dae4e
commit
a38391a6bc
@ -1,15 +1,16 @@
|
|||||||
discobot_username = 'discobot'
|
discobot_username = 'discobot'
|
||||||
user = User.find_by(id: -2)
|
|
||||||
|
|
||||||
if !user
|
|
||||||
suggested_username = UserNameSuggester.suggest(discobot_username)
|
|
||||||
|
|
||||||
|
def seed_primary_email
|
||||||
UserEmail.seed do |ue|
|
UserEmail.seed do |ue|
|
||||||
ue.id = -2
|
ue.id = -2
|
||||||
ue.email = "discobot_email"
|
ue.email = "discobot_email"
|
||||||
ue.primary = true
|
ue.primary = true
|
||||||
ue.user_id = -2
|
ue.user_id = -2
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
unless user = User.find_by(id: -2)
|
||||||
|
suggested_username = UserNameSuggester.suggest(discobot_username)
|
||||||
|
|
||||||
User.seed do |u|
|
User.seed do |u|
|
||||||
u.id = -2
|
u.id = -2
|
||||||
@ -37,6 +38,13 @@ if !user
|
|||||||
end
|
end
|
||||||
|
|
||||||
bot = User.find(-2)
|
bot = User.find(-2)
|
||||||
|
|
||||||
|
# ensure discobot has a primary email
|
||||||
|
unless bot.primary_email
|
||||||
|
seed_primary_email
|
||||||
|
bot.reload
|
||||||
|
end
|
||||||
|
|
||||||
bot.update!(admin: true, moderator: false)
|
bot.update!(admin: true, moderator: false)
|
||||||
|
|
||||||
bot.user_option.update!(
|
bot.user_option.update!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user