From b1035cc691705e3afb60bd53d80a7030757164f4 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 6 Mar 2019 12:30:36 -0500 Subject: [PATCH] FIX: NodeBB import details - mark imported users as active - do not strip @ from usernames in post content - improve uploads path matching --- script/import_scripts/nodebb/nodebb.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/script/import_scripts/nodebb/nodebb.rb b/script/import_scripts/nodebb/nodebb.rb index 3e5c616a5d6..45078de4239 100644 --- a/script/import_scripts/nodebb/nodebb.rb +++ b/script/import_scripts/nodebb/nodebb.rb @@ -144,6 +144,7 @@ class ImportScripts::NodeBB < ImportScripts::Base suspended_till: suspended_till, primary_group_id: group_id_from_imported_group_id(user["groupTitle"]), created_at: user["joindate"], + active: true, custom_fields: { import_pass: user["password"] }, @@ -197,13 +198,14 @@ class ImportScripts::NodeBB < ImportScripts::Base upload = UploadCreator.new(file, filename).create_for(imported_user.id) else - # remove "/assets/uploads/" from attachment + # remove "/assets/uploads/" and "/uploads" from attachment picture = picture.gsub("/assets/uploads", "") + picture = picture.gsub("/uploads", "") filepath = File.join(ATTACHMENT_DIR, picture) filename = File.basename(picture) unless File.exists?(filepath) - puts "Avatar file doesn't exist: #{filename}" + puts "Avatar file doesn't exist: #{filepath}" return nil end @@ -256,13 +258,14 @@ class ImportScripts::NodeBB < ImportScripts::Base upload = UploadCreator.new(file, filename).create_for(imported_user.id) else - # remove "/assets/uploads/" from attachment + # remove "/assets/uploads/" and "/uploads" from attachment picture = picture.gsub("/assets/uploads", "") + picture = picture.gsub("/uploads", "") filepath = File.join(ATTACHMENT_DIR, picture) filename = File.basename(picture) unless File.exists?(filepath) - puts "Background file doesn't exist: #{filename}" + puts "Background file doesn't exist: #{filepath}" return nil end @@ -509,13 +512,6 @@ class ImportScripts::NodeBB < ImportScripts::Base end end - # @username with dash to underscore - raw = raw.gsub(/@([a-zA-Z0-9-]+)/) do - username = $1 - - username.gsub('-', '_') - end - raw end end