From 4d1ace5de788b5429f4abc9a873cdd3b7f0d1388 Mon Sep 17 00:00:00 2001 From: Xavier Michelon Date: Thu, 30 Sep 2021 09:35:11 +0200 Subject: [PATCH] Other: Copy from All Mail allowed again. Creates duplicate. Added test scenario. --- internal/imap/mailbox_messages.go | 8 ++++---- .../features/bridge/imap/message/copy.feature | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/internal/imap/mailbox_messages.go b/internal/imap/mailbox_messages.go index 5313b776..990b82cf 100644 --- a/internal/imap/mailbox_messages.go +++ b/internal/imap/mailbox_messages.go @@ -243,6 +243,10 @@ func (im *imapMailbox) moveMessages(uid bool, seqSet *imap.SeqSet, targetLabel s // Called from go-imap in goroutines - we need to handle panics for each function. defer im.panicHandler.HandlePanic() + // Moving from All Mail is not allowed. + if im.storeMailbox.LabelID() == pmapi.AllMailLabel { + return errors.New("move from All Mail is not allowed") + } return im.labelMessages(uid, seqSet, targetLabel, true) } @@ -279,10 +283,6 @@ func (im *imapMailbox) labelMessages(uid bool, seqSet *imap.SeqSet, targetLabel } return errors.New("move from Sent to Inbox is not allowed") } - // Moving from All Mail is not allowed. - if im.storeMailbox.LabelID() == pmapi.AllMailLabel { - return errors.New("move from All Mail is not allowed") - } deletedIDs := []string{} allDeletedIDs, err := im.storeMailbox.GetDeletedAPIIDs() diff --git a/test/features/bridge/imap/message/copy.feature b/test/features/bridge/imap/message/copy.feature index 625190b5..d10eee2a 100644 --- a/test/features/bridge/imap/message/copy.feature +++ b/test/features/bridge/imap/message/copy.feature @@ -48,6 +48,25 @@ Feature: IMAP copy messages | from | to | subject | body | read | deleted | | john.doe@mail.com | user@pm.me | foo | hello | true | false | + Scenario: Copy message from All mail creates a duplicate + Given there is IMAP client selected in "All Mail" + When IMAP client copies message seq "1" to "Folders/mbox" + Then IMAP response is "OK" + And mailbox "INBOX" for "user" has 2 messages + And mailbox "INBOX" for "user" has messages + | from | to | subject | body | read | deleted | + | john.doe@mail.com | user@pm.me | foo | hello | true | false | + | jane.doe@mail.com | name@pm.me | bar | world | false | true | + And mailbox "All Mail" for "user" has 3 messages + And mailbox "All Mail" for "user" has messages + | from | to | subject | body | read | deleted | + | john.doe@mail.com | user@pm.me | foo | hello | true | false | + | jane.doe@mail.com | name@pm.me | bar | world | false | false | + And mailbox "Folders/mbox" for "user" has 1 messages + And mailbox "Folders/mbox" for "user" has messages + | from | to | subject | body | read | deleted | + | john.doe@mail.com | user@pm.me | foo | hello | true | false | + Scenario: Copy all messages to folder does move Given there is IMAP client selected in "INBOX" When IMAP client copies message seq "1:*" to "Folders/mbox"