[GODT-354] Do not label/unlabel messsages from All Mail folder

This commit is contained in:
Jakub
2020-05-14 10:24:34 +02:00
committed by Jakub Cuth
parent 9808c44714
commit 49cc49b1e2
2 changed files with 35 additions and 0 deletions

View File

@ -24,6 +24,8 @@ import (
bolt "go.etcd.io/bbolt"
)
var errAllMailOpNotAllowed = errors.New("operation not supported for 'All Mail' folder")
// GetMessage returns the `pmapi.Message` struct wrapped in `StoreMessage`
// tied to this mailbox.
func (storeMailbox *Mailbox) GetMessage(apiID string) (*Message, error) {
@ -78,6 +80,9 @@ func (storeMailbox *Mailbox) LabelMessages(apiIDs []string) error {
"label": storeMailbox.labelID,
"mailbox": storeMailbox.Name,
}).Trace("Labeling messages")
if storeMailbox.labelID == pmapi.AllMailLabel {
return errAllMailOpNotAllowed
}
defer storeMailbox.pollNow()
return storeMailbox.client().LabelMessages(apiIDs, storeMailbox.labelID)
}
@ -91,6 +96,9 @@ func (storeMailbox *Mailbox) UnlabelMessages(apiIDs []string) error {
"label": storeMailbox.labelID,
"mailbox": storeMailbox.Name,
}).Trace("Unlabeling messages")
if storeMailbox.labelID == pmapi.AllMailLabel {
return errAllMailOpNotAllowed
}
defer storeMailbox.pollNow()
return storeMailbox.client().UnlabelMessages(apiIDs, storeMailbox.labelID)
}