Bug: Gloda overwriting the Attachment flag for OpenPGP encrypted messages
Status: NEW
Priority: --
Created: 2021-10-13 15:56:37+00:00
Resolved: 2022-02-16 11:44:14+00:00

### Steps to reproduce

1. Create an OpenPGP encrypted message with *no signature* and at least one attachment.
2. Go to the folder view without selecting the message.
3. Click to the view the message.
4. Change the "read" status of the message in the message thread.

### Result

In step 2, the message is shown as having no attachments in the message thread.

In my personal 91 profile: in step 3 the message has an attachment list and is marked as having attachments in the message thread, and after step 4 it is cleared.

In my testing daily profile: the first time I open the message, in step 3 the message is still shown as having no attachments. But on subsequent viewings it acts the same as my personal profile.

(I don't think the difference between my personal and testing profile is significant, other than probably changing the details of when gloda is run on receiving a new message. I just pointed it out in case people reproducing see something different.)

### Expect

I can understand that in step 2, without the message being decrypted, it would not be possible to know if it has attachments. But after opening it, we should be taking the fact that the message has an attachment list as authoritative (with the exceptions of vcards bug 583572 and pgp keys bug 1678220).

## Origin

When viewing a message, the attachment flag is set based on what appears in the displayed attachment list (modulo vcards, and soon pgp keys) https://searchfox.org/comm-central/rev/b9c1d3f9ad38c4223958cff36522f3372a34f4dd/mail/base/content/msgHdrView.js#781

But when gloda is run on the message (which can be triggered by changing its read status) since gloda does not recognise that the encrypted message contains attachments, it thinks the message has none and unsets the attachment flag here https://searchfox.org/comm-central/rev/b9c1d3f9ad38c4223958cff36522f3372a34f4dd/mailnews/db/gloda/modules/GlodaFundAttr.jsm#592

Note this is why I specified *no signature* in the steps to reproduce because the plain `application/pgp-signature` is visible to gloda.

Note that gloda does have an `isEncrypted` flag, which is meant to handle this case (it sets `wasStreamed` to `false`). But the calculation (https://searchfox.org/comm-central/rev/b9c1d3f9ad38c4223958cff36522f3372a34f4dd/mailnews/db/gloda/modules/GlodaFundAttr.jsm#542-549) currently returns `false` for OpenPGP emails. Note that the `isEncrypted` doesn't seem to be read elsewhere except for pretty printing, like here https://searchfox.org/comm-central/rev/b9c1d3f9ad38c4223958cff36522f3372a34f4dd/mailnews/db/gloda/modules/MimeMessage.jsm#628

## Solutions?

So to sum up, the desired behaviour relies on "gloda thinks there are no attachments => message view thinks there are no attachments", which is actually broken for encrypted messages. Fixing the gloda `isEncrypted` flag *might* restore this. But I think we should consider if there is a cleaner solution that would guarantee this more explicitly because the logic used in the message view seems very separated to that in gloda.