mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 15:46:44 +00:00
Set flags by FLAGS (not using +/-FLAGS) do not change spam state
This commit is contained in:
committed by
Jakub Cuth
parent
7ff67f2217
commit
b4892855d4
@ -8,6 +8,8 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Reverted sending IMAP updates to be not blocking again.
|
* Reverted sending IMAP updates to be not blocking again.
|
||||||
|
### Fixed
|
||||||
|
* GODT-783 Settings flags by FLAGS (not using +/-FLAGS) do not change spam state.
|
||||||
|
|
||||||
## [Bridge 1.4.2] Forth
|
## [Bridge 1.4.2] Forth
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,10 @@ func (im *imapMailbox) UpdateMessagesFlags(uid bool, seqSet *imap.SeqSet, operat
|
|||||||
return im.addOrRemoveFlags(operation, messageIDs, flags)
|
return im.addOrRemoveFlags(operation, messageIDs, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setFlags is used for FLAGS command (not +FLAGS or -FLAGS), which means
|
||||||
|
// to set flags passed as an argument and unset the rest. For example,
|
||||||
|
// if message is not read, is flagged and is not deleted, call FLAGS \Seen
|
||||||
|
// should flag message as read, unflagged and keep undeleted.
|
||||||
func (im *imapMailbox) setFlags(messageIDs, flags []string) error { //nolint
|
func (im *imapMailbox) setFlags(messageIDs, flags []string) error { //nolint
|
||||||
seen := false
|
seen := false
|
||||||
flagged := false
|
flagged := false
|
||||||
@ -106,18 +110,19 @@ func (im *imapMailbox) setFlags(messageIDs, flags []string) error { //nolint
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spam should not be taken into action here as Outlook is using FLAGS
|
||||||
|
// without preserving junk flag. Probably it's because junk is not standard
|
||||||
|
// in the rfc3501 and thus Outlook expects calling FLAGS \Seen will not
|
||||||
|
// change the state of junk or other non-standard flags.
|
||||||
|
// Still, its safe to label as spam once any client sends the request.
|
||||||
|
if spam {
|
||||||
spamMailbox, err := im.storeAddress.GetMailbox("Spam")
|
spamMailbox, err := im.storeAddress.GetMailbox("Spam")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if spam {
|
|
||||||
if err := spamMailbox.LabelMessages(messageIDs); err != nil {
|
if err := spamMailbox.LabelMessages(messageIDs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if err := spamMailbox.UnlabelMessages(messageIDs); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
21
test/features/bridge/imap/message/update_spam.feature
Normal file
21
test/features/bridge/imap/message/update_spam.feature
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Feature: IMAP update messages in Spam folder
|
||||||
|
Background:
|
||||||
|
Given there is connected user "user"
|
||||||
|
# Messages are inserted in opposite way to keep increasing ID.
|
||||||
|
# Sequence numbers are then opposite than listed above.
|
||||||
|
And there are messages in mailbox "Spam" for "user"
|
||||||
|
| from | to | subject | body | read | starred | deleted |
|
||||||
|
| john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
|
||||||
|
| jane.doe@mail.com | name@pm.me | bar | world | true | true | false |
|
||||||
|
And there is IMAP client logged in as "user"
|
||||||
|
And there is IMAP client selected in "Spam"
|
||||||
|
|
||||||
|
Scenario: Mark message as read only
|
||||||
|
When IMAP client marks message "2" with "\Seen"
|
||||||
|
Then IMAP response is "OK"
|
||||||
|
And message "1" in "Spam" for "user" is marked as read
|
||||||
|
And message "1" in "Spam" for "user" is marked as unstarred
|
||||||
|
And API mailbox "Spam" for "user" has messages
|
||||||
|
| from | to | subject |
|
||||||
|
| john.doe@mail.com | user@pm.me | foo |
|
||||||
|
| jane.doe@mail.com | name@pm.me | bar |
|
||||||
Reference in New Issue
Block a user