I was looking in imports/base.rb as well.
AFAIK its only implemented for SMF2 (thanks to @elberet)
I havenāt looked into it yet, but I guess parts of it could be moved to the base importer and be reused for phpBB.
Iāve placed the Discourse-specific part of that code into ImportScripts::Base#create_upload
.
The method expects, in order, the uploaderās Discourse user id, the current path of the file and the original filename; before handing the file over to Discourse, it creates a temporary copy of the uploaded file, so the source data is guaranteed to remain undisturbed. The return value is the Discourse model object representing the upload.
The real magic happens in ImportScripts::Smf2#convert_message_body
, but this part is very much specific to the import source. There is one bit that may be of interest to others working on importers: #get_upload_markdown
and #v8
, which is mostly lifted from Discourseās PrettyText
module. Discourse has a utility function that generates the proper and localized HTML markup for an uploaded file, but this is implemented in JavaScript.
Unfortunately, that bit of code is rather hacky, as evidenced by the recently reported problems other users had with getting attachments imported properly ā so moving it into the importer base may not be a good idea.
I added code to the phpbb3 importer to support attachments.
To use it, youāll need to edit at least one constant near the top of the script: ATTACHMENTS_BASE_DIR
and possibly AUTHORIZED_EXTENSIONS
. In my case, I was given a big tar.gz file with all the attachments, so I extracted them somewhere, set ATTACHMENTS_BASE_DIR
to that directory, and most of the attachments imported successfully.
Some attachments fail to import because of this error:
Couldn't find phpbb_attachments record for post.id = 9876, import_id = 9123, real_filename = blahblah.jpg
In those cases, the phpbb_attachments table really is missing records for those attachments, so thereās no way to import them. Maybe your phpbb databases wonāt have this problem.
I used a hacky solution to this tooā¦ so, thereās room for improvement.
@neil Can you confirm the following for me? I notice you used the following line:
PostRevisor.new(post).revise!(post.user, new_raw, {bypass_bump: true, edit_reason: 'Migrate from PHPBB3'})
Specifically bypass_bump: true
- does this absolutely not bump the topic at all?
I donāt want users getting any kind of notification from my reprocessing of posts.
Thatās right. It wonāt bump the topic to the top of topic lists.
Thank you so much for this, @neil!
Can ATTACHMENTS_BASE_DIR be a remote directory or should I ftp the files across to the new site?:
Itās a local directory. Being able to download the files during the import would be pretty fancy, but I was given a tar file.
Where can I find that script?
Read the first post, this is now complete. Open new support topics for support on this.