Merge release/golden-gate into devel

This commit is contained in:
Jakub
2021-01-27 11:06:10 +01:00
254 changed files with 9588 additions and 5963 deletions

View File

@ -21,8 +21,10 @@ import (
"bufio"
"fmt"
"net"
"strings"
"sync"
"github.com/ProtonMail/proton-bridge/pkg/message"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -163,7 +165,7 @@ func (c *IMAPClient) Search(query string) *IMAPResponse {
// Message
func (c *IMAPClient) Append(mailboxName, msg string) *IMAPResponse {
cmd := fmt.Sprintf("APPEND \"%s\" (\\Seen) \"25-Mar-2021 00:30:00 +0100\" {%d}\r\n%s", mailboxName, len(msg), msg)
cmd := fmt.Sprintf("APPEND \"%s\" (\\Seen) \"%s\" {%d}\r\n%s", mailboxName, parseAppendDate(msg), len(msg), msg)
return c.SendCommand(cmd)
}
@ -175,10 +177,20 @@ func (c *IMAPClient) AppendBody(mailboxName, subject, from, to, body string) *IM
msg += body
msg += "\r\n"
cmd := fmt.Sprintf("APPEND \"%s\" (\\Seen) \"25-Mar-2021 00:30:00 +0100\" {%d}\r\n%s", mailboxName, len(msg), msg)
cmd := fmt.Sprintf("APPEND \"%s\" (\\Seen) \"%s\" {%d}\r\n%s", mailboxName, parseAppendDate(msg), len(msg), msg)
return c.SendCommand(cmd)
}
func parseAppendDate(msg string) string {
date := "25-Mar-2021 00:30:00 +0100"
if m, _, _, _, err := message.Parse(strings.NewReader(msg)); err == nil {
if t, err := m.Header.Date(); err == nil {
date = t.Format("02-Jan-2006 15:04:05 -0700")
}
}
return date
}
func (c *IMAPClient) Copy(ids, newMailboxName string) *IMAPResponse {
return c.SendCommand(fmt.Sprintf("COPY %s \"%s\"", ids, newMailboxName))
}
@ -231,7 +243,8 @@ func (c *IMAPClient) Expunge() *IMAPResponse {
return c.SendCommand("EXPUNGE")
}
// IDLE
// Extennsions
// Extennsions: IDLE
func (c *IMAPClient) StartIDLE() *IMAPResponse {
c.idling = true
@ -242,3 +255,9 @@ func (c *IMAPClient) StopIDLE() {
c.idling = false
fmt.Fprintf(c.conn, "%s\r\n", "DONE")
}
// Extennsions: ID
func (c *IMAPClient) ID(request string) *IMAPResponse {
return c.SendCommand(fmt.Sprintf("ID (%v)", request))
}