Skip to content

Allow messages with no text or HTML body and no attachments. - #247

Open
iamamoose wants to merge 1 commit into
apache:masterfrom
iamamoose:nontextbody
Open

Allow messages with no text or HTML body and no attachments.#247
iamamoose wants to merge 1 commit into
apache:masterfrom
iamamoose:nontextbody

Conversation

@iamamoose

Copy link
Copy Markdown
Member

These are fairly common for example a calendar entry might be sent as "Content-Type: text/calendar".  I just made it so that if there is no recognised body it just uses whatever the last section it found was, regardless of content type.

Example:
mjc11a-sanitised.mbox.txt

…re fairly common for example a calendar entry might be sent as "Content-Type: text/calendar".  I just made it so that if there is no recognised body it just uses whatever the last section it found was, regardless of content type.
@iamamoose

Copy link
Copy Markdown
Member Author

Trying to import the attached file without this patch:

$ pipenv run ./import-mbox.py --source /tmp/mjc11a-sanitised.mbox.txt --html2text --lid mark@awe.com --dry
...
Thread-1: Slurping /tmp/mjc11a-sanitised.mbox.txt
Thread-1: Failed to parse: Return=mark@awe.com Message-Id=<195589600>
Thread-1: Parsed 0 records (failed: 1) from /tmp/mjc11a-sanitised.mbox.txt
Thread-1: Done, 0 elements left to slurp
All done! 0 records inserted after 0 seconds. 1 records were bad and ignored. 0 duplicates were ignored.

with it, and setting the config option

$ pipenv run ./import-mbox.py --source /tmp/mjc11a-sanitised.mbox.txt --html2text --lid mark@awe.com --dry
...
Thread-1: Slurping /tmp/mjc11a-sanitised.mbox.txt
No text or html body found, using what we have
Thread-1: Parsed 1 records (failed: 0) from /tmp/mjc11a-sanitised.mbox.txt
Thread-1: Done, 0 elements left to slurp
All done! 1 records inserted after 0 seconds. 0 records were bad and ignored. 0 duplicates were ignored.

Comment thread tools/archiver.py
elif (
body is None
):
last_random = Body(part)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If allow_nontext_body is not set, then last_random is not needed, and should not be calculated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants