webmail: for replies/forwards, add button "send and archive thread" next to the "send" button, and give it a control+shift+Enter shortcut

the regular send shortcut is control+Enter. the shift enables "archive thread".
there is no configuration option, you'll always get the button, but only for
reply/forward, not for new compose.

we may do "send and move thread to thrash", but let's wait until people want it.

for github issue #135 by mattfbacon
This commit is contained in:
Mechiel Lukkien
2024-04-19 21:03:18 +02:00
parent b54e903f01
commit 5229d01601
8 changed files with 188 additions and 125 deletions

View File

@ -207,6 +207,7 @@ type SubmitMessage struct {
UserAgent string // User-Agent header added if not empty.
RequireTLS *bool // For "Require TLS" extension during delivery.
FutureRelease *time.Time // If set, time (in the future) when message should be delivered from queue.
ArchiveThread bool // If set, thread is archived after sending message.
}
// ForwardAttachments references attachments by a list of message.Part paths.
@ -740,6 +741,28 @@ func (w Webmail) MessageSubmit(ctx context.Context, m SubmitMessage) {
err = acc.RetrainMessages(ctx, log, tx, []store.Message{rm}, false)
xcheckf(ctx, err, "retraining messages after reply/forward")
}
// Move messages from this thread still in this mailbox to the designated Archive
// mailbox.
if m.ArchiveThread {
mbArchive, err := bstore.QueryTx[store.Mailbox](tx).FilterEqual("Archive", true).Get()
if err == bstore.ErrAbsent {
xcheckuserf(ctx, errors.New("not configured"), "looking up designated archive mailbox")
}
xcheckf(ctx, err, "looking up designated archive mailbox")
var msgIDs []int64
q := bstore.QueryTx[store.Message](tx)
q.FilterNonzero(store.Message{ThreadID: rm.ThreadID, MailboxID: rm.MailboxID})
q.FilterEqual("Expunged", false)
err = q.IDs(&msgIDs)
xcheckf(ctx, err, "listing messages in thread to archive")
if len(msgIDs) > 0 {
var nchanges []store.Change
modseq, nchanges = xops.MessageMoveMailbox(ctx, log, acc, tx, msgIDs, mbArchive, modseq)
changes = append(changes, nchanges...)
}
}
}
sentmb, err := bstore.QueryTx[store.Mailbox](tx).FilterEqual("Sent", true).Get()