mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 11:58:47 +08:00
FIX: NodeBB import details
- mark imported users as active - do not strip @ from usernames in post content - improve uploads path matching
This commit is contained in:
parent
167d85c21f
commit
b1035cc691
|
@ -144,6 +144,7 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
suspended_till: suspended_till,
|
suspended_till: suspended_till,
|
||||||
primary_group_id: group_id_from_imported_group_id(user["groupTitle"]),
|
primary_group_id: group_id_from_imported_group_id(user["groupTitle"]),
|
||||||
created_at: user["joindate"],
|
created_at: user["joindate"],
|
||||||
|
active: true,
|
||||||
custom_fields: {
|
custom_fields: {
|
||||||
import_pass: user["password"]
|
import_pass: user["password"]
|
||||||
},
|
},
|
||||||
|
@ -197,13 +198,14 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
|
|
||||||
upload = UploadCreator.new(file, filename).create_for(imported_user.id)
|
upload = UploadCreator.new(file, filename).create_for(imported_user.id)
|
||||||
else
|
else
|
||||||
# remove "/assets/uploads/" from attachment
|
# remove "/assets/uploads/" and "/uploads" from attachment
|
||||||
picture = picture.gsub("/assets/uploads", "")
|
picture = picture.gsub("/assets/uploads", "")
|
||||||
|
picture = picture.gsub("/uploads", "")
|
||||||
filepath = File.join(ATTACHMENT_DIR, picture)
|
filepath = File.join(ATTACHMENT_DIR, picture)
|
||||||
filename = File.basename(picture)
|
filename = File.basename(picture)
|
||||||
|
|
||||||
unless File.exists?(filepath)
|
unless File.exists?(filepath)
|
||||||
puts "Avatar file doesn't exist: #{filename}"
|
puts "Avatar file doesn't exist: #{filepath}"
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -256,13 +258,14 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
|
|
||||||
upload = UploadCreator.new(file, filename).create_for(imported_user.id)
|
upload = UploadCreator.new(file, filename).create_for(imported_user.id)
|
||||||
else
|
else
|
||||||
# remove "/assets/uploads/" from attachment
|
# remove "/assets/uploads/" and "/uploads" from attachment
|
||||||
picture = picture.gsub("/assets/uploads", "")
|
picture = picture.gsub("/assets/uploads", "")
|
||||||
|
picture = picture.gsub("/uploads", "")
|
||||||
filepath = File.join(ATTACHMENT_DIR, picture)
|
filepath = File.join(ATTACHMENT_DIR, picture)
|
||||||
filename = File.basename(picture)
|
filename = File.basename(picture)
|
||||||
|
|
||||||
unless File.exists?(filepath)
|
unless File.exists?(filepath)
|
||||||
puts "Background file doesn't exist: #{filename}"
|
puts "Background file doesn't exist: #{filepath}"
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -509,13 +512,6 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @username with dash to underscore
|
|
||||||
raw = raw.gsub(/@([a-zA-Z0-9-]+)/) do
|
|
||||||
username = $1
|
|
||||||
|
|
||||||
username.gsub('-', '_')
|
|
||||||
end
|
|
||||||
|
|
||||||
raw
|
raw
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user