Other: Copy from All Mail allowed again.

Creates duplicate.
Added test scenario.
This commit is contained in:
Xavier Michelon
2021-09-30 09:35:11 +02:00
committed by Jakub Cuth
parent 1250621a4d
commit 4d1ace5de7
2 changed files with 23 additions and 4 deletions

View File

@ -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. // Called from go-imap in goroutines - we need to handle panics for each function.
defer im.panicHandler.HandlePanic() 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) 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") 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{} deletedIDs := []string{}
allDeletedIDs, err := im.storeMailbox.GetDeletedAPIIDs() allDeletedIDs, err := im.storeMailbox.GetDeletedAPIIDs()

View File

@ -48,6 +48,25 @@ Feature: IMAP copy messages
| from | to | subject | body | read | deleted | | from | to | subject | body | read | deleted |
| john.doe@mail.com | user@pm.me | foo | hello | true | false | | 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 Scenario: Copy all messages to folder does move
Given there is IMAP client selected in "INBOX" Given there is IMAP client selected in "INBOX"
When IMAP client copies message seq "1:*" to "Folders/mbox" When IMAP client copies message seq "1:*" to "Folders/mbox"