2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-09-06 04:03:30 -04:00
|
|
|
# kind of odd, but we need it, we also need to nuke usage of User from inside migrations
|
|
|
|
# very poor form
|
2023-12-06 18:04:45 -05:00
|
|
|
user = User.find_by("id <> #{Discourse::SYSTEM_USER_ID} and username_lower = 'system'")
|
2013-09-06 00:07:23 -04:00
|
|
|
if user
|
2013-09-06 03:28:37 -04:00
|
|
|
user.username = UserNameSuggester.suggest("system")
|
2013-09-06 00:07:23 -04:00
|
|
|
user.save
|
|
|
|
end
|
|
|
|
|
2017-04-26 14:47:36 -04:00
|
|
|
UserEmail.seed do |ue|
|
|
|
|
ue.id = -1
|
|
|
|
ue.email = "no_email"
|
|
|
|
ue.primary = true
|
2023-12-06 18:04:45 -05:00
|
|
|
ue.user_id = Discourse::SYSTEM_USER_ID
|
2017-04-26 14:47:36 -04:00
|
|
|
end
|
|
|
|
|
2013-09-06 00:07:23 -04:00
|
|
|
User.seed do |u|
|
2023-12-06 18:04:45 -05:00
|
|
|
u.id = Discourse::SYSTEM_USER_ID
|
2013-09-06 03:28:37 -04:00
|
|
|
u.name = "system"
|
|
|
|
u.username = "system"
|
|
|
|
u.username_lower = "system"
|
2013-09-06 00:07:23 -04:00
|
|
|
u.password = SecureRandom.hex
|
|
|
|
u.active = true
|
|
|
|
u.admin = true
|
|
|
|
u.moderator = true
|
|
|
|
u.approved = true
|
2014-09-05 01:20:39 -04:00
|
|
|
u.trust_level = TrustLevel[4]
|
2013-09-06 00:07:23 -04:00
|
|
|
end
|
2014-06-16 20:46:30 -04:00
|
|
|
|
2023-12-06 18:04:45 -05:00
|
|
|
UserOption.where(user_id: Discourse::SYSTEM_USER_ID).update_all(
|
2019-03-15 10:55:11 -04:00
|
|
|
email_messages_level: UserOption.email_level_types[:never],
|
|
|
|
email_level: UserOption.email_level_types[:never],
|
2016-02-16 23:46:19 -05:00
|
|
|
)
|
|
|
|
|
2023-12-06 18:04:45 -05:00
|
|
|
Group.user_trust_level_change!(Discourse::SYSTEM_USER_ID, TrustLevel[4])
|
2015-07-27 05:07:42 -04:00
|
|
|
|
|
|
|
# User for the smoke tests
|
|
|
|
if ENV["SMOKE"] == "1"
|
2017-04-26 14:47:36 -04:00
|
|
|
UserEmail.seed do |ue|
|
|
|
|
ue.id = 0
|
|
|
|
ue.email = "smoke_user@discourse.org"
|
|
|
|
ue.primary = true
|
|
|
|
ue.user_id = 0
|
|
|
|
end
|
|
|
|
|
2015-07-27 05:07:42 -04:00
|
|
|
smoke_user =
|
|
|
|
User
|
|
|
|
.seed do |u|
|
|
|
|
u.id = 0
|
|
|
|
u.name = "smoke_user"
|
|
|
|
u.username = "smoke_user"
|
|
|
|
u.username_lower = "smoke_user"
|
|
|
|
u.password = "P4ssw0rd"
|
|
|
|
u.active = true
|
|
|
|
u.approved = true
|
|
|
|
u.approved_at = Time.now
|
|
|
|
u.trust_level = TrustLevel[3]
|
|
|
|
end
|
|
|
|
.first
|
|
|
|
|
2016-02-17 05:57:06 -05:00
|
|
|
UserOption.where(user_id: smoke_user.id).update_all(
|
|
|
|
email_digests: false,
|
2019-03-15 10:55:11 -04:00
|
|
|
email_messages_level: UserOption.email_level_types[:never],
|
|
|
|
email_level: UserOption.email_level_types[:never],
|
2016-02-17 05:57:06 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true)
|
2015-07-27 05:07:42 -04:00
|
|
|
end
|