From 1ba8e8948d5c0eb4762fb4f9dcd15bed74afc852 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 7 Jun 2018 18:13:57 -0400 Subject: [PATCH] FIX: add support for string avatar_type values in PHPBB3 importer --- .../phpbb3/importers/avatar_importer.rb | 20 +++++++++---------- .../phpbb3/support/constants.rb | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/script/import_scripts/phpbb3/importers/avatar_importer.rb b/script/import_scripts/phpbb3/importers/avatar_importer.rb index a9cd22d4c97..2178ed800c4 100644 --- a/script/import_scripts/phpbb3/importers/avatar_importer.rb +++ b/script/import_scripts/phpbb3/importers/avatar_importer.rb @@ -47,16 +47,16 @@ module ImportScripts::PhpBB3 def get_avatar_path(avatar_type, filename) case avatar_type - when Constants::AVATAR_TYPE_UPLOADED then + when Constants::AVATAR_TYPE_UPLOADED, Constants::AVATAR_TYPE_STRING_UPLOADED then filename.gsub!(/_[0-9]+\./, '.') # we need 1337.jpg, not 1337_2983745.jpg get_uploaded_path(filename) - when Constants::AVATAR_TYPE_GALLERY then + when Constants::AVATAR_TYPE_GALLERY, Constants::AVATAR_TYPE_STRING_GALLERY then get_gallery_path(filename) - when Constants::AVATAR_TYPE_REMOTE then + when Constants::AVATAR_TYPE_REMOTE, Constants::AVATAR_TYPE_STRING_REMOTE then download_avatar(filename) - else - Rails.logger.error("Invalid avatar type #{avatar_type}. Skipping...") - nil + else + puts "Invalid avatar type #{avatar_type}. Skipping..." + nil end end @@ -97,13 +97,13 @@ module ImportScripts::PhpBB3 def is_allowed_avatar_type?(avatar_type) case avatar_type - when Constants::AVATAR_TYPE_UPLOADED then + when Constants::AVATAR_TYPE_UPLOADED, Constants::AVATAR_TYPE_STRING_UPLOADED then @settings.import_uploaded_avatars - when Constants::AVATAR_TYPE_REMOTE then + when Constants::AVATAR_TYPE_REMOTE, Constants::AVATAR_TYPE_STRING_REMOTE then @settings.import_remote_avatars - when Constants::AVATAR_TYPE_GALLERY then + when Constants::AVATAR_TYPE_GALLERY, Constants::AVATAR_TYPE_STRING_GALLERY then @settings.import_gallery_avatars - else + else false end end diff --git a/script/import_scripts/phpbb3/support/constants.rb b/script/import_scripts/phpbb3/support/constants.rb index af7482d5da6..6e9612e6785 100644 --- a/script/import_scripts/phpbb3/support/constants.rb +++ b/script/import_scripts/phpbb3/support/constants.rb @@ -19,6 +19,10 @@ module ImportScripts::PhpBB3 AVATAR_TYPE_REMOTE = 2 AVATAR_TYPE_GALLERY = 3 + AVATAR_TYPE_STRING_UPLOADED = 'avatar.driver.upload' + AVATAR_TYPE_STRING_REMOTE = 'avatar.driver.remote' + AVATAR_TYPE_STRING_GALLERY = 'avatar.driver.local' + FORUM_TYPE_CATEGORY = 0 FORUM_TYPE_POST = 1 FORUM_TYPE_LINK = 2