aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/models.go4
-rw-r--r--worker/imap/imap.go10
-rw-r--r--worker/lib/parse.go9
3 files changed, 18 insertions, 5 deletions
diff --git a/models/models.go b/models/models.go
index b55024ab..d730229c 100644
--- a/models/models.go
+++ b/models/models.go
@@ -90,6 +90,9 @@ func (mi *MessageInfo) InReplyTo() (msgid string, err error) {
if mi == nil {
return "", errors.New("msg is nil")
}
+ if mi.Envelope != nil && mi.Envelope.InReplyTo != "" {
+ return mi.Envelope.InReplyTo, nil
+ }
if mi.RFC822Headers == nil {
return "", errors.New("header is nil")
}
@@ -200,6 +203,7 @@ type Envelope struct {
Cc []*mail.Address
Bcc []*mail.Address
MessageId string
+ InReplyTo string
}
// OriginalMail is helper struct used for reply/forward
diff --git a/worker/imap/imap.go b/worker/imap/imap.go
index 93b8a945..6e1341b2 100644
--- a/worker/imap/imap.go
+++ b/worker/imap/imap.go
@@ -1,6 +1,8 @@
package imap
import (
+ "strings"
+
"github.com/emersion/go-imap"
"git.sr.ht/~rjarry/aerc/models"
@@ -50,11 +52,8 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
// we strip the msgid of "<>" in order to be more compatible with go-message
// which wants to handle msgids without the markers
- // note this is a very naive way of doing it but probably good enough
- msgID := e.MessageId
- if len(msgID) > 1 && msgID[0] == '<' && msgID[len(msgID)-1] == '>' {
- msgID = msgID[1 : len(msgID)-1]
- }
+ msgID := strings.TrimSuffix(strings.TrimPrefix(e.MessageId, "<"), ">")
+ inReplyTo := strings.TrimSuffix(strings.TrimPrefix(e.InReplyTo, "<"), ">")
return &models.Envelope{
Date: e.Date,
@@ -65,6 +64,7 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
Cc: translateAddresses(e.Cc),
Bcc: translateAddresses(e.Bcc),
MessageId: msgID,
+ InReplyTo: inReplyTo,
}
}
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index f57a56ac..6b33d246 100644
--- a/worker/lib/parse.go
+++ b/worker/lib/parse.go
@@ -164,6 +164,14 @@ func parseEnvelope(h *mail.Header) (*models.Envelope, error) {
return nil, err
}
}
+ irtList, err := h.MsgIDList("in-reply-to")
+ if err != nil {
+ return nil, err
+ }
+ irt := ""
+ if len(irtList) > 0 {
+ irt = irtList[0]
+ }
date, err := parseDate(h)
if err != nil {
// still return a valid struct plus a sentinel date parsing error
@@ -179,6 +187,7 @@ func parseEnvelope(h *mail.Header) (*models.Envelope, error) {
To: to,
Cc: cc,
Bcc: bcc,
+ InReplyTo: irt,
}, err
}