Open Bug 1876407 Opened 8 months ago Updated 4 months ago

Refactor nsParseMailMessageState et al

Categories

(MailNews Core :: General, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: benc, Unassigned)

References

Details

At core, nsParseMailMessageState (and nsMsgMailboxParser and nsParseNewMailState) are responsible for taking a header block from a message and parsing out the fields required by the msgDB (i.e. everything you'll find in nsIMsgDBHdr).

But over time so much extra responsibility has accumulated here that the core message parsing has so many side effects that it's quite intractable.

In addition to parsing out message headers for the DB, they were handling writing to mbox files, invoking filters on new messages, showing alerts in the GUI, triggering notifications etc etc etc...

This stuff all needs some major refactoring.
Really, there should just be a nice simple routine which takes the header section of a message and parses out the fields wanted by the database. Everything else should be handled in more appropriate places.

see:
https://searchfox.org/comm-central/source/mailnews/local/src/nsParseMailbox.h
https://searchfox.org/comm-central/source/mailnews/local/src/nsParseMailbox.cpp

Bug 1873282 is a good indication of the kind of problem the overcomplication here causes.

See Also: → 1890253
See Also: → 1888790

Bug 1888790 throws up a few new thoughts:
New-message filtering is handled differently for pop3 and for imap. POP3 handles it as part of the header parsing (nsParseNewMailState). This is quite a pain.
To refactor the header parsing code we need to excise the filtering from nsParseNewMailState and get POP3 to handle it elsewhere.
Ideally, new-message filtering should be unified and protocol agnostic!
So we need to document how filtering is implemented currently for various protocols, then hopefully unify it in a single place.

You need to log in before you can comment on or make changes to this bug.