diff --git a/internal/imap/mailbox_messages.go b/internal/imap/mailbox_messages.go index 3a28fca1..ae2b50d5 100644 --- a/internal/imap/mailbox_messages.go +++ b/internal/imap/mailbox_messages.go @@ -266,6 +266,10 @@ 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/move.feature b/test/features/bridge/imap/message/move.feature index 2b4d1c01..e2d27532 100644 --- a/test/features/bridge/imap/message/move.feature +++ b/test/features/bridge/imap/message/move.feature @@ -80,16 +80,12 @@ Feature: IMAP move messages Scenario: Move message from All Mail is not possible Given there is IMAP client selected in "All Mail" When IMAP client moves message seq "1" to "Folders/folder" - Then IMAP response is "OK" + Then IMAP response is "NO move from All Mail is not allowed" And mailbox "All Mail" for "user" has messages | from | to | subject | | john.doe@mail.com | user@pm.me | foo | | jane.doe@mail.com | name@pm.me | bar | - And mailbox "Folders/folder" for "user" has messages - | from | to | subject | - | john.doe@mail.com | user@pm.me | baz | - And API endpoint "PUT /mail/v4/messages/label" is called - And API endpoint "PUT /mail/v4/messages/unlabel" is not called + And mailbox "Folders/folder" for "user" has 0 messages Scenario: Move message from Inbox to Sent is not possible Given there is IMAP client selected in "INBOX"