mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 06:21:12 +08:00
Revert "Merge branch 'master' of https://github.com/discourse/discourse"
This reverts commit e62a85cf6fd81a2a34aff6144bd36b9ac459964a, reversing changes made to 2660c2e21d84bea667e1ea339f91cda352328062.
This commit is contained in:
@ -4,20 +4,20 @@ discobot_username = 'discobot'
|
||||
|
||||
def seed_primary_email
|
||||
UserEmail.seed do |ue|
|
||||
ue.id = DiscourseNarrativeBot::BOT_USER_ID
|
||||
ue.id = -2
|
||||
ue.email = "discobot_email"
|
||||
ue.primary = true
|
||||
ue.user_id = DiscourseNarrativeBot::BOT_USER_ID
|
||||
ue.user_id = -2
|
||||
end
|
||||
end
|
||||
|
||||
unless user = User.find_by(id: DiscourseNarrativeBot::BOT_USER_ID)
|
||||
unless user = User.find_by(id: -2)
|
||||
suggested_username = UserNameSuggester.suggest(discobot_username)
|
||||
|
||||
seed_primary_email
|
||||
|
||||
User.seed do |u|
|
||||
u.id = DiscourseNarrativeBot::BOT_USER_ID
|
||||
u.id = -2
|
||||
u.name = discobot_username
|
||||
u.username = suggested_username
|
||||
u.username_lower = suggested_username.downcase
|
||||
@ -26,9 +26,22 @@ unless user = User.find_by(id: DiscourseNarrativeBot::BOT_USER_ID)
|
||||
u.approved = true
|
||||
u.trust_level = TrustLevel[4]
|
||||
end
|
||||
|
||||
# TODO Pull the user avatar from that thread for now. In the future, pull it from a local file or from some central discobot repo.
|
||||
if !Rails.env.test?
|
||||
begin
|
||||
UserAvatar.import_url_for_user(
|
||||
"https://cdn.discourse.org/dev/uploads/default/original/2X/e/edb63d57a720838a7ce6a68f02ba4618787f2299.png",
|
||||
User.find(-2),
|
||||
override_gravatar: true
|
||||
)
|
||||
rescue
|
||||
# In case the avatar can't be downloaded, don't fail seed
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
bot = User.find(DiscourseNarrativeBot::BOT_USER_ID)
|
||||
bot = User.find(-2)
|
||||
|
||||
# ensure discobot has a primary email
|
||||
unless bot.primary_email
|
||||
@ -49,4 +62,4 @@ if !bot.user_profile.bio_raw
|
||||
)
|
||||
end
|
||||
|
||||
Group.user_trust_level_change!(DiscourseNarrativeBot::BOT_USER_ID, TrustLevel[4])
|
||||
Group.user_trust_level_change!(-2, TrustLevel[4])
|
||||
|
@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ClearLastGravatarDownloadAttemptOnUserAvatars < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
UPDATE user_avatars
|
||||
SET last_gravatar_download_attempt = null
|
||||
WHERE user_id = -2 AND custom_upload_id IS NULL AND gravatar_upload_id IS NULL
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user