mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 04:34:13 -06:00
REFACTOR: more 'fake_email' to base importer
This commit is contained in:
parent
ce0a51665e
commit
afa22a0c6f
@ -253,7 +253,7 @@ class ImportScripts::Base
|
|||||||
|
|
||||||
if user_id_from_imported_user_id(import_id)
|
if user_id_from_imported_user_id(import_id)
|
||||||
skipped += 1
|
skipped += 1
|
||||||
elsif u[:email].present?
|
else
|
||||||
new_user = create_user(u, import_id)
|
new_user = create_user(u, import_id)
|
||||||
created_user(new_user)
|
created_user(new_user)
|
||||||
|
|
||||||
@ -270,9 +270,6 @@ class ImportScripts::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
failed += 1
|
|
||||||
puts "Skipping user id #{import_id} because email is blank"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -314,8 +311,8 @@ class ImportScripts::Base
|
|||||||
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name].presence || opts[:email])
|
opts[:username] = UserNameSuggester.suggest(opts[:username] || opts[:name].presence || opts[:email])
|
||||||
end
|
end
|
||||||
|
|
||||||
unless opts[:email].match(EmailValidator.email_regex)
|
unless opts[:email][EmailValidator.email_regex]
|
||||||
opts[:email] = "invalid#{SecureRandom.hex}@no-email.invalid"
|
opts[:email] = fake_email
|
||||||
puts "Invalid email #{original_email} for #{opts[:username]}. Using: #{opts[:email]}"
|
puts "Invalid email #{original_email} for #{opts[:username]}. Using: #{opts[:email]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -881,4 +878,8 @@ class ImportScripts::Base
|
|||||||
offset += batch_size
|
offset += batch_size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fake_email
|
||||||
|
SecureRandom.hex << "@domain.com"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1032,10 +1032,6 @@ SQL
|
|||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_email
|
|
||||||
SecureRandom.hex << "@domain.com"
|
|
||||||
end
|
|
||||||
|
|
||||||
def mysql_query(sql)
|
def mysql_query(sql)
|
||||||
@client.query(sql, cache_rows: true)
|
@client.query(sql, cache_rows: true)
|
||||||
end
|
end
|
||||||
|
@ -518,10 +518,6 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
|||||||
|
|
||||||
raw
|
raw
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_email
|
|
||||||
SecureRandom.hex << "@domain.com"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ImportScripts::NodeBB.new.perform
|
ImportScripts::NodeBB.new.perform
|
||||||
|
@ -551,10 +551,6 @@ EOM
|
|||||||
Time.zone.at(@tz.utc_to_local(timestamp))
|
Time.zone.at(@tz.utc_to_local(timestamp))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_email
|
|
||||||
SecureRandom.hex << "@domain.com"
|
|
||||||
end
|
|
||||||
|
|
||||||
def mysql_query(sql)
|
def mysql_query(sql)
|
||||||
@client.query(sql, cache_rows: true)
|
@client.query(sql, cache_rows: true)
|
||||||
end
|
end
|
||||||
|
@ -931,10 +931,6 @@ EOM
|
|||||||
Time.zone.at(@tz.utc_to_local(timestamp))
|
Time.zone.at(@tz.utc_to_local(timestamp))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_email
|
|
||||||
SecureRandom.hex << "@domain.com"
|
|
||||||
end
|
|
||||||
|
|
||||||
def mysql_query(sql)
|
def mysql_query(sql)
|
||||||
@client.query(sql, cache_rows: true)
|
@client.query(sql, cache_rows: true)
|
||||||
end
|
end
|
||||||
|
@ -621,10 +621,6 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||||||
Time.zone.at(@tz.utc_to_local(timestamp))
|
Time.zone.at(@tz.utc_to_local(timestamp))
|
||||||
end
|
end
|
||||||
|
|
||||||
def fake_email
|
|
||||||
SecureRandom.hex << "@domain.com"
|
|
||||||
end
|
|
||||||
|
|
||||||
def mysql_query(sql)
|
def mysql_query(sql)
|
||||||
@client.query(sql, cache_rows: false)
|
@client.query(sql, cache_rows: false)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user