improvements to the mbox import script

* ignores dot-files and empty emails
* new setting to prefer HTML over plaintext emails during import
* restore original site settings at the end of import
* elided content of HTML mails was not put inside details block
This commit is contained in:
Gerhard Schlager
2017-11-18 13:53:21 +01:00
parent 6dda87c49b
commit 32dd1e66be
5 changed files with 23 additions and 11 deletions

View File

@ -13,10 +13,11 @@ module ImportScripts::Mbox
@database = Database.new(@settings.data_dir, @settings.batch_size)
end
def change_site_settings
super
SiteSetting.enable_staged_users = true
def get_site_settings_for_import
settings = super
settings[:enable_staged_users] = true
settings[:incoming_email_prefer_html] = @settings.prefer_html
settings
end
protected
@ -120,7 +121,7 @@ module ImportScripts::Mbox
when Email::Receiver::formats[:markdown]
body = email_body
body << attachment_html if attachment_html.present?
body << elided if elided.present?
body << Email::Receiver.elided_html(elided) if elided.present?
when Email::Receiver::formats[:plaintext]
body = %|[plaintext]\n#{escape_tags(email_body)}\n[/plaintext]|
body << %|\n[attachments]\n#{escape_tags(attachment_html)}\n[/attachments]| if attachment_html.present?