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:
James Houlahan
2022-10-19 08:00:45 +02:00
parent a7a7d9a3d4
commit 04b6571cb8
12 changed files with 259 additions and 39 deletions

View File

@ -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))
}