webmail: more helpful error message when emptying a mailbox that is already empty

and mention in a tooltip too that "empty mailbox" only affects messages in the
mailbox, not submailboxes or their messages.

prompted by a question on matrix/irc
This commit is contained in:
Mechiel Lukkien
2025-01-22 20:09:19 +01:00
parent 315f10d5f2
commit f15f2d68fc
3 changed files with 7 additions and 3 deletions

View File

@ -1276,9 +1276,13 @@ func (Webmail) MailboxEmpty(ctx context.Context, mailboxID int64) {
qm.FilterEqual("Expunged", false)
qm.SortAsc("UID")
qm.Gather(&expunged)
_, err = qm.UpdateNonzero(store.Message{ModSeq: modseq, Expunged: true})
n, err := qm.UpdateNonzero(store.Message{ModSeq: modseq, Expunged: true})
xcheckf(ctx, err, "deleting messages")
if n == 0 {
xcheckf(ctx, errors.New("no messages in mailbox"), "emptying mailbox")
}
// Remove Recipients.
anyIDs := make([]any, len(expunged))
for i, m := range expunged {