aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-11-08 16:15:26 +0100
committerReto Brunner <reto@labrat.space>2020-11-14 15:40:13 +0100
commit7b12f2d1ea791139022b63029bbd8616564355f3 (patch)
tree9a2b412fda42bf519ca84639a6d2dfcd53f3f174 /commands/msg
parentdaf214a1f8b9ee1f8eabff9b1a2485eceb19cbd0 (diff)
downloadaerc-7b12f2d1ea791139022b63029bbd8616564355f3.tar.gz
reply: add References header
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/reply.go29
1 files changed, 28 insertions, 1 deletions
diff --git a/commands/msg/reply.go b/commands/msg/reply.go
index fcd83419..778c0efc 100644
--- a/commands/msg/reply.go
+++ b/commands/msg/reply.go
@@ -154,7 +154,10 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
h.SetAddressList("from", []*mail.Address{from})
h.SetSubject(subject)
h.SetMsgIDList("in-reply-to", []string{msg.Envelope.MessageId})
- //TODO: references header
+ err = setReferencesHeader(h, msg.RFC822Headers)
+ if err != nil {
+ aerc.PushError(fmt.Sprintf("could not set references: %v", err))
+ }
original := models.OriginalMail{
From: format.FormatAddresses(msg.Envelope.From),
Date: msg.Envelope.Date,
@@ -248,3 +251,27 @@ func (s addrSet) Contains(a *mail.Address) bool {
_, ok := s[a.Address]
return ok
}
+
+//setReferencesHeader adds the references header to target based on parent
+//according to RFC2822
+func setReferencesHeader(target, parent *mail.Header) error {
+ refs, err := parent.MsgIDList("references")
+ if err != nil {
+ return err
+ }
+ if len(refs) == 0 {
+ // according to the RFC we need to fall back to in-reply-to only if
+ // References is not set
+ refs, err = parent.MsgIDList("in-reply-to")
+ if err != nil {
+ return err
+ }
+ }
+ msgID, err := parent.MessageID()
+ if err != nil {
+ return err
+ }
+ refs = append(refs, msgID)
+ target.SetMsgIDList("references", refs)
+ return nil
+}