mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 17:13:25 +08:00
REFACTOR: more 'fake_email' to base importer
This commit is contained in:
@ -253,7 +253,7 @@ class ImportScripts::Base
|
||||
|
||||
if user_id_from_imported_user_id(import_id)
|
||||
skipped += 1
|
||||
elsif u[:email].present?
|
||||
else
|
||||
new_user = create_user(u, import_id)
|
||||
created_user(new_user)
|
||||
|
||||
@ -270,9 +270,6 @@ class ImportScripts::Base
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
failed += 1
|
||||
puts "Skipping user id #{import_id} because email is blank"
|
||||
end
|
||||
end
|
||||
|
||||
@ -314,8 +311,8 @@ class ImportScripts::Base
|
||||
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name].presence || opts[:email])
|
||||
end
|
||||
|
||||
unless opts[:email].match(EmailValidator.email_regex)
|
||||
opts[:email] = "invalid#{SecureRandom.hex}@no-email.invalid"
|
||||
unless opts[:email][EmailValidator.email_regex]
|
||||
opts[:email] = fake_email
|
||||
puts "Invalid email #{original_email} for #{opts[:username]}. Using: #{opts[:email]}"
|
||||
end
|
||||
|
||||
@ -881,4 +878,8 @@ class ImportScripts::Base
|
||||
offset += batch_size
|
||||
end
|
||||
end
|
||||
|
||||
def fake_email
|
||||
SecureRandom.hex << "@domain.com"
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user