mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 09:14:39 +03:00
implement message threading in backend and webmail
we match messages to their parents based on the "references" and "in-reply-to" headers (requiring the same base subject), and in absense of those headers we also by only base subject (against messages received max 4 weeks ago). we store a threadid with messages. all messages in a thread have the same threadid. messages also have a "thread parent ids", which holds all id's of parent messages up to the thread root. then there is "thread missing link", which is set when a referenced immediate parent wasn't found (but possibly earlier ancestors can still be found and will be in thread parent ids". threads can be muted: newly delivered messages are automatically marked as read/seen. threads can be marked as collapsed: if set, the webmail collapses the thread to a single item in the basic threading view (default is to expand threads). the muted and collapsed fields are copied from their parent on message delivery. the threading is implemented in the webmail. the non-threading mode still works as before. the new default threading mode "unread" automatically expands only the threads with at least one unread (not seen) meessage. the basic threading mode "on" expands all threads except when explicitly collapsed (as saved in the thread collapsed field). new shortcuts for navigation/interaction threads have been added, e.g. go to previous/next thread root, toggle collapse/expand of thread (or double click), toggle mute of thread. some previous shortcuts have changed, see the help for details. the message threading are added with an explicit account upgrade step, automatically started when an account is opened. the upgrade is done in the background because it will take too long for large mailboxes to block account operations. the upgrade takes two steps: 1. updating all message records in the database to add a normalized message-id and thread base subject (with "re:", "fwd:" and several other schemes stripped). 2. going through all messages in the database again, reading the "references" and "in-reply-to" headers from disk, and matching against their parents. this second step is also done at the end of each import of mbox/maildir mailboxes. new deliveries are matched immediately against other existing messages, currently no attempt is made to rematch previously delivered messages (which could be useful for related messages being delivered out of order). the threading is not yet exposed over imap.
This commit is contained in:
35
doc.go
35
doc.go
@ -77,6 +77,7 @@ low-maintenance self-hosted email.
|
||||
mox ensureparsed account
|
||||
mox recalculatemailboxcounts account
|
||||
mox message parse message.eml
|
||||
mox reassignthreads [account]
|
||||
|
||||
Many commands talk to a running mox instance, through the ctl file in the data
|
||||
directory. Specify the configuration file (that holds the path to the data
|
||||
@ -882,6 +883,40 @@ incorrect. This command will find, fix and print them.
|
||||
Parse message, print JSON representation.
|
||||
|
||||
usage: mox message parse message.eml
|
||||
|
||||
# mox reassignthreads
|
||||
|
||||
Reassign message threads.
|
||||
|
||||
For all accounts, or optionally only the specified account.
|
||||
|
||||
Threading for all messages in an account is first reset, and new base subject
|
||||
and normalized message-id saved with the message. Then all messages are
|
||||
evaluated and matched against their parents/ancestors.
|
||||
|
||||
Messages are matched based on the References header, with a fall-back to an
|
||||
In-Reply-To header, and if neither is present/valid, based only on base
|
||||
subject.
|
||||
|
||||
A References header typically points to multiple previous messages in a
|
||||
hierarchy. From oldest ancestor to most recent parent. An In-Reply-To header
|
||||
would have only a message-id of the parent message.
|
||||
|
||||
A message is only linked to a parent/ancestor if their base subject is the
|
||||
same. This ensures unrelated replies, with a new subject, are placed in their
|
||||
own thread.
|
||||
|
||||
The base subject is lower cased, has whitespace collapsed to a single
|
||||
space, and some components removed: leading "Re:", "Fwd:", "Fw:", or bracketed
|
||||
tag (that mailing lists often add, e.g. "[listname]"), trailing "(fwd)", or
|
||||
enclosing "[fwd: ...]".
|
||||
|
||||
Messages are linked to all their ancestors. If an intermediate parent/ancestor
|
||||
message is deleted in the future, the message can still be linked to the earlier
|
||||
ancestors. If the direct parent already wasn't available while matching, this is
|
||||
stored as the message having a "missing link" to its stored ancestors.
|
||||
|
||||
usage: mox reassignthreads [account]
|
||||
*/
|
||||
package main
|
||||
|
||||
|
Reference in New Issue
Block a user