Update SMF1 import

- Properly import avatar when they use an external image
- Don't import the same attachment twice
This commit is contained in:
Régis Hanol 2018-07-12 16:55:30 +02:00
parent 6bc0f97668
commit 5c4534d895
1 changed files with 5 additions and 2 deletions

View File

@ -113,6 +113,7 @@ class ImportScripts::Smf1 < ImportScripts::Base
, memberIP2
, is_activated
, additionalGroups
, avatar
, id_attach
, attachmentType
, filename
@ -167,7 +168,9 @@ class ImportScripts::Smf1 < ImportScripts::Base
end
# avatar
avatar_url = if u["attachmentType"] == 0 && u["id_attach"].present?
avatar_url = if u["avatar"].present?
u["avatar"]
elsif u["attachmentType"] == 0 && u["id_attach"].present?
"#{FORUM_URL}/index.php?action=dlattach;attach=#{u["id_attach"]};type=avatar"
elsif u["attachmentType"] == 1 && u["filename"].present?
"#{FORUM_URL}/avatar-members/#{u["filename"]}"
@ -402,7 +405,7 @@ class ImportScripts::Smf1 < ImportScripts::Base
if upload = create_upload(post.user_id, path, u["filename"])
html = html_for_upload(upload, u["filename"])
unless post.raw[html]
unless post.raw[html] || PostUpload.where(upload: upload, post: post).exists?
post.raw += "\n\n#{html}\n\n"
post.save
PostUpload.create(upload: upload, post: post)