This commit is contained in:
parent
0365e8edc4
commit
e883759f45
@ -2,7 +2,6 @@ package imap_server
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/tls"
|
||||
@ -35,7 +34,6 @@ var clientUnLogin *imapclient.Client
|
||||
var clientLogin *imapclient.Client
|
||||
var imapTestAddr string
|
||||
var imapTestProtocolCode string
|
||||
var imapDebug bytes.Buffer
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
wd, err := os.Getwd()
|
||||
@ -87,7 +85,6 @@ func TestMain(m *testing.M) {
|
||||
}()
|
||||
|
||||
options := &imapclient.Options{
|
||||
DebugWriter: &imapDebug,
|
||||
WordDecoder: &mime.WordDecoder{CharsetReader: charset.Reader},
|
||||
TLSConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
|
||||
@ -289,7 +289,6 @@ func write(ctx *context.Context, w *imapserver.FetchWriter, emailList []*respons
|
||||
return err
|
||||
}
|
||||
}
|
||||
fmt.Printf("IMAP FETCH write sequence=%d uid=%d requested_uid=%t\n", sequence, uid, options.UID)
|
||||
var htmlSize uint32
|
||||
var textSize uint32
|
||||
attachmentSizes := make([]uint32, len(traEmail.Attachments))
|
||||
|
||||
@ -267,11 +267,9 @@ func getEmailListByUidList(ctx *context.Context, groupName string, req ImapListR
|
||||
}
|
||||
sql += " ORDER BY id"
|
||||
var relations []*response.UserEmailUIDData
|
||||
fmt.Printf("IMAP UID SQL=%s params=%v\n", sql, params)
|
||||
if err := db.Instance.SQL(sql, params...).Find(&relations); err != nil {
|
||||
return nil, fmt.Errorf("query mailbox UID list: %w", err)
|
||||
}
|
||||
fmt.Printf("IMAP UID SQL result=%d\n", len(relations))
|
||||
return hydrateIMAPEmailResponses(relations)
|
||||
}
|
||||
|
||||
@ -332,7 +330,6 @@ func hydrateIMAPEmailResponses(relations []*response.UserEmailUIDData) ([]*respo
|
||||
if err := db.Instance.Table("email").Select("*").Where(Eq{"id": emailIDs}).Find(&stored); err != nil {
|
||||
return nil, fmt.Errorf("query mailbox messages: %w", err)
|
||||
}
|
||||
fmt.Printf("IMAP hydrate email_ids=%v stored=%d\n", emailIDs, len(stored))
|
||||
messageByID := make(map[int]*response.EmailResponseData, len(stored))
|
||||
for _, message := range stored {
|
||||
if message != nil {
|
||||
@ -351,6 +348,5 @@ func hydrateIMAPEmailResponses(relations []*response.UserEmailUIDData) ([]*respo
|
||||
copyMessage.UeId = relation.ID
|
||||
result = append(result, ©Message)
|
||||
}
|
||||
fmt.Printf("IMAP hydrate result=%d\n", len(result))
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package imap_server
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.pcux.cn/xuans/Smail/db"
|
||||
@ -164,17 +162,10 @@ func TestAuditFetchWildcardUIDMustReturnLastMessage(t *testing.T) {
|
||||
if _, err := clientLogin.Select("INBOX", nil).Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
imapDebug.Reset()
|
||||
messages, err := clientLogin.Fetch(imap.UIDSetNum(0), &imap.FetchOptions{UID: true}).Collect()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("imap_wire=%q", imapDebug.String())
|
||||
wire := imapDebug.String()
|
||||
wantUID := "FETCH (UID " + strconv.Itoa(relation.ID) + ")"
|
||||
if !strings.Contains(wire, wantUID) {
|
||||
t.Fatalf("UID FETCH * 未在协议响应中返回最大 UID: wire=%q", wire)
|
||||
}
|
||||
// go-imap/v2 beta.5 的动态 UID 集合 Contains(*) 固定返回 false,
|
||||
// 因而客户端会丢弃合法的动态 UID 响应;静态 UID 用于验证响应解析本身。
|
||||
if len(messages) != 0 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user