aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email/lore/parse.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-10-10 17:45:29 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-10-21 16:05:49 +0000
commit67ef0ea2b648fd72cc7f0e3ec50c5b2fa144b80c (patch)
tree998f1ff64ab65b94118ccd229c0d725e7b6d97e7 /pkg/email/lore/parse.go
parent9832ed61ae41048a549b0194edc9dcade0851e76 (diff)
pkg/email/lore: wrap the Email object
Wrapping the email.Email object will let us add lore-specific fields to it at a later point.
Diffstat (limited to 'pkg/email/lore/parse.go')
-rw-r--r--pkg/email/lore/parse.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/pkg/email/lore/parse.go b/pkg/email/lore/parse.go
index 9d1a010f5..d71e2a362 100644
--- a/pkg/email/lore/parse.go
+++ b/pkg/email/lore/parse.go
@@ -20,7 +20,7 @@ type Thread struct {
MessageID string
Type dashapi.DiscussionType
BugIDs []string
- Messages []*email.Email
+ Messages []*Email
}
// Series represents a single patch series sent over email.
@@ -35,19 +35,19 @@ type Series struct {
type Patch struct {
Seq int
- *email.Email
+ *Email
}
// Threads extracts individual threads from a list of emails.
-func Threads(emails []*email.Email) []*Thread {
+func Threads(emails []*Email) []*Thread {
return listThreads(emails, 0)
}
-func listThreads(emails []*email.Email, maxDepth int) []*Thread {
+func listThreads(emails []*Email, maxDepth int) []*Thread {
ctx := &parseCtx{
maxDepth: maxDepth,
- messages: map[string]*email.Email{},
- next: map[*email.Email][]*email.Email{},
+ messages: map[string]*Email{},
+ next: map[*Email][]*Email{},
}
for _, email := range emails {
ctx.record(email)
@@ -57,7 +57,7 @@ func listThreads(emails []*email.Email, maxDepth int) []*Thread {
}
// PatchSeries is similar to Threads, but returns only the patch series submitted to the mailing lists.
-func PatchSeries(emails []*email.Email) []*Series {
+func PatchSeries(emails []*Email) []*Series {
var ret []*Series
// Normally, all following series patches are sent in response to the first email sent.
// So there's no sense to look at deeper replies.
@@ -180,17 +180,17 @@ func parsePatchSubject(subject string) (PatchSubject, bool) {
type parseCtx struct {
maxDepth int
threads []*Thread
- messages map[string]*email.Email
- next map[*email.Email][]*email.Email
+ messages map[string]*Email
+ next map[*Email][]*Email
}
-func (c *parseCtx) record(msg *email.Email) {
+func (c *parseCtx) record(msg *Email) {
c.messages[msg.MessageID] = msg
}
func (c *parseCtx) process() {
// List messages for which we dont't have ancestors.
- nodes := []*email.Email{}
+ nodes := []*Email{}
for _, msg := range c.messages {
if msg.InReplyTo == "" || c.messages[msg.InReplyTo] == nil {
nodes = append(nodes, msg)
@@ -220,15 +220,15 @@ func (c *parseCtx) process() {
}
}
-func (c *parseCtx) visit(msg *email.Email, thread *Thread, depth int) {
+func (c *parseCtx) visit(msg *Email, thread *Thread, depth int) {
var oldInfo *email.OldThreadInfo
if thread != nil {
oldInfo = &email.OldThreadInfo{
ThreadType: thread.Type,
}
}
- msgType := DiscussionType(msg)
- switch email.NewMessageAction(msg, msgType, oldInfo) {
+ msgType := DiscussionType(msg.Email)
+ switch email.NewMessageAction(msg.Email, msgType, oldInfo) {
case email.ActionIgnore:
thread = nil
case email.ActionAppend:
@@ -238,7 +238,7 @@ func (c *parseCtx) visit(msg *email.Email, thread *Thread, depth int) {
MessageID: msg.MessageID,
Subject: msg.Subject,
Type: msgType,
- Messages: []*email.Email{msg},
+ Messages: []*Email{msg},
}
c.threads = append(c.threads, thread)
}