mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 13:16:53 +00:00
Other: Handle Seen/Flagged IMAP flags when APPENDing a message
When an IMAP client appends a message to a mailbox, it can specify which flags it wants the appended message to have. We need to handle these in a proton-specific way; not-seen messages need to be imported with the Unread bool set to true, and flagged messages need to additionally be imported with the Starred label.
This commit is contained in:
@ -19,7 +19,10 @@ package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/bradenaw/juniper/iterator"
|
||||
"github.com/bradenaw/juniper/xslices"
|
||||
@ -380,6 +383,23 @@ func (s *scenario) imapClientExpunges(clientID string) error {
|
||||
return client.Expunge(nil)
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientAppendsTheFollowingMessageToMailbox(clientID string, mailbox string, docString *godog.DocString) error {
|
||||
_, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
return clientAppend(client, mailbox, docString.Content)
|
||||
}
|
||||
|
||||
func (s *scenario) imapClientAppendsToMailbox(clientID string, file, mailbox string) error {
|
||||
_, client := s.t.getIMAPClient(clientID)
|
||||
|
||||
b, err := os.ReadFile(filepath.Join("testdata", file))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientAppend(client, mailbox, string(b))
|
||||
}
|
||||
|
||||
func clientList(client *client.Client) []*imap.MailboxInfo {
|
||||
resCh := make(chan *imap.MailboxInfo)
|
||||
|
||||
@ -490,3 +510,7 @@ func clientStore(client *client.Client, from, to int, item imap.StoreItem, flags
|
||||
|
||||
return iterator.Collect(iterator.Chan(resCh)), nil
|
||||
}
|
||||
|
||||
func clientAppend(client *client.Client, mailbox string, literal string) error {
|
||||
return client.Append(mailbox, []string{}, time.Now(), strings.NewReader(literal))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user