feat(GODT-1264): constraint on Scheduled mailbox in connector + Integration tests.

This commit is contained in:
Xavier Michelon
2023-02-15 07:37:09 +00:00
parent 13db1b0db8
commit 08dab2d115
8 changed files with 74 additions and 66 deletions

View File

@ -380,7 +380,7 @@ func (conn *imapConnector) GetMessageLiteral(ctx context.Context, id imap.Messag
func (conn *imapConnector) AddMessagesToMailbox(ctx context.Context, messageIDs []imap.MessageID, mailboxID imap.MailboxID) error {
defer conn.goPollAPIEvents(false)
if mailboxID == proton.AllMailLabel {
if isAllMailOrScheduled(mailboxID) {
return fmt.Errorf("not allowed")
}
@ -391,7 +391,7 @@ func (conn *imapConnector) AddMessagesToMailbox(ctx context.Context, messageIDs
func (conn *imapConnector) RemoveMessagesFromMailbox(ctx context.Context, messageIDs []imap.MessageID, mailboxID imap.MailboxID) error {
defer conn.goPollAPIEvents(false)
if mailboxID == proton.AllMailLabel {
if isAllMailOrScheduled(mailboxID) {
return fmt.Errorf("not allowed")
}
@ -440,8 +440,8 @@ func (conn *imapConnector) MoveMessages(ctx context.Context, messageIDs []imap.M
if (labelFromID == proton.InboxLabel && labelToID == proton.SentLabel) ||
(labelFromID == proton.SentLabel && labelToID == proton.InboxLabel) ||
labelFromID == proton.AllMailLabel ||
labelToID == proton.AllMailLabel {
isAllMailOrScheduled(labelFromID) ||
isAllMailOrScheduled(labelToID) {
return false, fmt.Errorf("not allowed")
}
@ -691,3 +691,7 @@ func toIMAPMailbox(label proton.Label, flags, permFlags, attrs imap.FlagSet) ima
Attributes: attrs,
}
}
func isAllMailOrScheduled(mailboxID imap.MailboxID) bool {
return (mailboxID == proton.AllMailLabel) || (mailboxID == proton.AllScheduledLabel)
}