add .OriginalMIMEType variable to reply template
This commit is contained in:
parent
5255585b3b
commit
d238272bdb
4 changed files with 39 additions and 18 deletions
|
@ -157,6 +157,17 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
buf.ReadFrom(reader)
|
buf.ReadFrom(reader)
|
||||||
original.Text = buf.String()
|
original.Text = buf.String()
|
||||||
|
if len(msg.BodyStructure.Parts) == 0 {
|
||||||
|
original.MIMEType = fmt.Sprintf("%s/%s",
|
||||||
|
msg.BodyStructure.MIMEType, msg.BodyStructure.MIMESubType)
|
||||||
|
} else {
|
||||||
|
// TODO: still will be "multipart/mixed" for mixed mails with
|
||||||
|
// attachments, fix this after aerc could handle responding to
|
||||||
|
// such mails
|
||||||
|
original.MIMEType = fmt.Sprintf("%s/%s",
|
||||||
|
msg.BodyStructure.Parts[0].MIMEType,
|
||||||
|
msg.BodyStructure.Parts[0].MIMESubType)
|
||||||
|
}
|
||||||
addTab()
|
addTab()
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -60,6 +60,12 @@ available always.
|
||||||
Example:
|
Example:
|
||||||
{{.Subject}}
|
{{.Subject}}
|
||||||
|
|
||||||
|
*MIME Type*
|
||||||
|
MIME Type is available for quoted reply.
|
||||||
|
|
||||||
|
- OriginalMIMEType: MIME type info of quoted mail part. Usually
|
||||||
|
"text/plain" or "text/html".
|
||||||
|
|
||||||
*Original Message*
|
*Original Message*
|
||||||
When using quoted reply or forward, the original message is available.
|
When using quoted reply or forward, the original message is available.
|
||||||
It can be used using two functions that are available to templates.
|
It can be used using two functions that are available to templates.
|
||||||
|
|
|
@ -25,6 +25,7 @@ type TemplateData struct {
|
||||||
OriginalText string
|
OriginalText string
|
||||||
OriginalFrom []*mail.Address
|
OriginalFrom []*mail.Address
|
||||||
OriginalDate time.Time
|
OriginalDate time.Time
|
||||||
|
OriginalMIMEType string
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplateData() TemplateData {
|
func TestTemplateData() TemplateData {
|
||||||
|
@ -39,6 +40,7 @@ func TestTemplateData() TemplateData {
|
||||||
Date: time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
|
Date: time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
|
||||||
From: "John Doe <john@example.com>",
|
From: "John Doe <john@example.com>",
|
||||||
Text: "This is only a test text",
|
Text: "This is only a test text",
|
||||||
|
MIMEType: "text/plain",
|
||||||
}
|
}
|
||||||
|
|
||||||
return ParseTemplateData(defaults, original)
|
return ParseTemplateData(defaults, original)
|
||||||
|
@ -56,6 +58,7 @@ func ParseTemplateData(defaults map[string]string, original models.OriginalMail)
|
||||||
OriginalText: original.Text,
|
OriginalText: original.Text,
|
||||||
OriginalFrom: parseAddressList(original.From),
|
OriginalFrom: parseAddressList(original.From),
|
||||||
OriginalDate: originalDate,
|
OriginalDate: originalDate,
|
||||||
|
OriginalMIMEType: original.MIMEType,
|
||||||
}
|
}
|
||||||
return td
|
return td
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,4 +170,5 @@ type OriginalMail struct {
|
||||||
Date string
|
Date string
|
||||||
From string
|
From string
|
||||||
Text string
|
Text string
|
||||||
|
MIMEType string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue