Support of UID EXPUNGE

This commit is contained in:
Michal Horejsek
2021-01-20 13:16:27 +01:00
parent 07c100bd66
commit 1909ceed67
6 changed files with 101 additions and 23 deletions

View File

@ -208,14 +208,35 @@ func (storeMailbox *Mailbox) MarkMessagesUndeleted(apiIDs []string) error {
// If the mailbox is All Mail or All Sent, it does nothing.
// If the mailbox is Trash or Spam and message is not in any other mailbox, messages is deleted.
// In all other cases the message is only removed from the mailbox.
func (storeMailbox *Mailbox) RemoveDeleted() error {
// If nil is passed, all messages with \Deleted flag are removed.
// In other cases only messages with \Deleted flag and included in the passed list.
func (storeMailbox *Mailbox) RemoveDeleted(apiIDs []string) error {
storeMailbox.log.Trace("Deleting messages")
apiIDs, err := storeMailbox.GetDeletedAPIIDs()
deletedAPIIDs, err := storeMailbox.GetDeletedAPIIDs()
if err != nil {
return err
}
if apiIDs == nil {
apiIDs = deletedAPIIDs
} else {
filteredAPIIDs := []string{}
for _, apiID := range apiIDs {
found := false
for _, deletedAPIID := range deletedAPIIDs {
if apiID == deletedAPIID {
found = true
break
}
}
if found {
filteredAPIIDs = append(filteredAPIIDs, apiID)
}
}
apiIDs = filteredAPIIDs
}
if len(apiIDs) == 0 {
storeMailbox.log.Debug("List to expunge is empty")
return nil