Attachment flag not working when set to false
Opened this issue · 4 comments
Here is my case:
I don't want to save the attachments on my file system (Doing other things with them) so i specified the flag of attachments
to false
According to the comment in the example - attachments: true, // download attachments as they are encountered to the project directory
I infered that if I give a false value, it's not going to download them.
Even with false
value it downloads them.
If you open index.js
you can see the problem in the checks:
// line 21
if (options.attachments && options.attachmentOptions && options.attachmentOptions.stream) {
this.mailParserOptions.streamAttachments = true;
}
If attachments
is false
then this.mailParserOptions.streamAttachments
will be undefined.
Down below, on parse end, we have the following check:
if (!self.mailParserOptions.streamAttachments && mail.attachments) {
It happens to be if(!undefined && mail.attachments)
- !undefined
is true
and if we have attacments, mail.attachments
will be true, so even if I say - don't download attachments via the options, it will download them anyway.
I am not pull requesting the fix since it requires changing 2 lines of code ;)
If you want - I will make a patch.
But first - reproduce the bug!
Down below, on parse end, we have the following check:
if (!self.mailParserOptions.streamAttachments && mail.attachments) {
It happens to be if(!undefined && mail.attachments) - !undefined is true and if we have attacments, mail.attachments will be true, so even if I say - don't download attachments via the options, it will download them anyway.
In your case, !undefined is true but mail.attachments will be false if you don't want attachments which will not parse attachments.
Am i missing something here?
Hey @chirag04, think the issue is that mail.attachments refers to whether the email has attachments - which will be true - different from the user setting options.attachments
I am also experiencing this issue. Would be nice to have a fix. Sending attachments to dev/null for now.
This might of been solved with the latest pr #32, but npm hasnt been updated with a new version. I have v0.1.7
The lastest branch is published on npm. (v0.1.8)
Can you guys confirm if this is still an issue?