imap: fix not being able to delete mails and [2000] IDs required

* Advertise imap.DeletedFlag on permanent flags
* Check if `mbox.deleted` has elements before sending API request
This commit is contained in:
MrViK 2020-12-17 13:16:02 +01:00 committed by Simon Ser
parent b4e52ac715
commit 4903cb08dd
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 8 additions and 2 deletions

View File

@ -62,7 +62,7 @@ func (mbox *mailbox) Info() (*imap.MailboxInfo, error) {
func (mbox *mailbox) Status(items []imap.StatusItem) (*imap.MailboxStatus, error) {
mbox.u.Lock()
flags := []string{imap.SeenFlag, imap.DeletedFlag}
permFlags := []string{imap.SeenFlag}
permFlags := []string{imap.SeenFlag, imap.DeletedFlag}
for _, flag := range mbox.u.flags {
flags = append(flags, flag)
permFlags = append(permFlags, flag)
@ -550,8 +550,14 @@ func (mbox *mailbox) Expunge() error {
return err
}
apiIDs := make([]string, 0, len(mbox.deleted))
mbox.Lock()
if len(mbox.deleted) == 0 {
mbox.Unlock()
return nil // Nothing to do
}
apiIDs := make([]string, 0, len(mbox.deleted))
for apiID := range mbox.deleted {
apiIDs = append(apiIDs, apiID)
}