mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46:44 +00:00
GODT-1415: Only messages which are in Spam should be moved to INBOX once they are marked as not-a-spam.
This is regression of GODT-963
This commit is contained in:
@ -182,7 +182,7 @@ func (im *imapMailbox) addOrRemoveFlags(operation imap.FlagsOp, messageIDs, flag
|
||||
case imap.AnsweredFlag, imap.DraftFlag, imap.RecentFlag:
|
||||
// Not supported.
|
||||
case strings.ToLower(message.AppleMailJunkFlag), strings.ToLower(message.ThunderbirdJunkFlag):
|
||||
storeMailbox, err := im.storeAddress.GetMailbox("Spam")
|
||||
spamMailbox, err := im.storeAddress.GetMailbox("Spam")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -191,24 +191,31 @@ func (im *imapMailbox) addOrRemoveFlags(operation imap.FlagsOp, messageIDs, flag
|
||||
// No label removal is necessary because Spam and Inbox are both exclusive labels so the backend
|
||||
// will automatically take care of label removal.
|
||||
case imap.AddFlags:
|
||||
if err := storeMailbox.LabelMessages(messageIDs); err != nil {
|
||||
if err := spamMailbox.LabelMessages(messageIDs); err != nil {
|
||||
return err
|
||||
}
|
||||
case imap.RemoveFlags:
|
||||
// when removing junk flag, the message should be moved to the INBOX folder.
|
||||
if err := storeMailbox.UnlabelMessages(messageIDs); err != nil {
|
||||
return err
|
||||
// During spam flag removal only messages which
|
||||
// are in Spam folder should be moved to Inbox.
|
||||
// For other messages it is NOOP.
|
||||
messagesInSpam := []string{}
|
||||
for _, mID := range messageIDs {
|
||||
if uid := spamMailbox.GetUIDList([]string{mID}); len(*uid) != 0 {
|
||||
messagesInSpam = append(messagesInSpam, mID)
|
||||
}
|
||||
}
|
||||
if len(messagesInSpam) != 0 {
|
||||
inboxMailbox, err := im.storeAddress.GetMailbox("INBOX")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := inboxMailbox.LabelMessages(messageIDs); err != nil {
|
||||
if err := inboxMailbox.LabelMessages(messagesInSpam); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -30,7 +30,16 @@ func (api *FakePMAPI) isLabelFolder(labelID string) bool {
|
||||
return bool(label.Exclusive)
|
||||
}
|
||||
}
|
||||
return labelID == pmapi.InboxLabel || labelID == pmapi.ArchiveLabel || labelID == pmapi.SentLabel
|
||||
switch labelID {
|
||||
case pmapi.InboxLabel,
|
||||
pmapi.TrashLabel,
|
||||
pmapi.SpamLabel,
|
||||
pmapi.ArchiveLabel,
|
||||
pmapi.SentLabel,
|
||||
pmapi.DraftLabel:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (api *FakePMAPI) ListLabels(context.Context) ([]*pmapi.Label, error) {
|
||||
|
||||
@ -20,7 +20,7 @@ Feature: IMAP update messages in Spam folder
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
|
||||
Scenario Outline: Removing flag "junk" or adding flags "nojunk" moves message to INBOX
|
||||
Scenario Outline: Move from Spam to INBOX when client <operation> <flag>
|
||||
When IMAP client <operation> flags "<flag>" <suffix> message seq "1"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 1 messages
|
||||
@ -38,3 +38,25 @@ Feature: IMAP update messages in Spam folder
|
||||
| removes | from | junk |
|
||||
| removes | from | Junk |
|
||||
| removes | from | $Junk |
|
||||
|
||||
Scenario Outline: Do not move from Archive to INBOX when client <operation> <flag>
|
||||
Given there are messages in mailbox "Archive" for "user"
|
||||
| id | from | to | subject | body | read | starred | deleted |
|
||||
| 1 | john.doe@mail.com | user@pm.me | Archived | hello | false | false | false |
|
||||
And there is IMAP client selected in "Archive"
|
||||
When IMAP client <operation> flags "<flag>" <suffix> message seq "1"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 0 messages
|
||||
And mailbox "Archive" for "user" has 1 messages
|
||||
And mailbox "Archive" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | Archived |
|
||||
Examples:
|
||||
| operation | suffix | flag |
|
||||
| adds | to | nojunk |
|
||||
| adds | to | NoJunk |
|
||||
| removes | from | junk |
|
||||
| removes | from | Junk |
|
||||
| removes | from | $Junk |
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user