aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-12-04 09:49:53 -0500
committerDrew DeVault <sir@cmpwn.com>2019-12-04 09:49:53 -0500
commiteef662c60677355b47b8903c619b742c1a91d3d6 (patch)
treedf2b8b3f82e9618da64ae159d68bba8d91d5bf43 /widgets
parentabd9e78f024580d476cb299a575a7aa54c53a4b4 (diff)
downloadaerc-eef662c60677355b47b8903c619b742c1a91d3d6.tar.gz
Revert "Parse headers from template"
This reverts commit 31e3e9f56e0b8123f0238537112496b407055aef.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/compose.go42
1 files changed, 3 insertions, 39 deletions
diff --git a/widgets/compose.go b/widgets/compose.go
index 6e527cb0..62aaafee 100644
--- a/widgets/compose.go
+++ b/widgets/compose.go
@@ -179,7 +179,8 @@ func (c *Composer) AddTemplate(template string, data interface{}) error {
if err != nil {
return err
}
- return c.addTemplate(bytes.NewReader(templateText))
+ c.PrependContents(bytes.NewReader(templateText))
+ return nil
}
func (c *Composer) AddTemplateFromString(template string, data interface{}) error {
@@ -191,44 +192,7 @@ func (c *Composer) AddTemplateFromString(template string, data interface{}) erro
if err != nil {
return err
}
- return c.addTemplate(bytes.NewReader(templateText))
-}
-
-func (c *Composer) addTemplate(tmpl io.Reader) error {
- reader, err := mail.CreateReader(tmpl)
- if err != nil {
- return errors.Wrap(err, "mail.CreateReader")
- }
- defer reader.Close()
-
- // populate header editors
- header := reader.Header
- mhdr := (*message.Header)(&header.Header)
- for _, editor := range c.editors {
- if mhdr.Has(editor.name) {
- editor.input.Set(mhdr.Get(editor.name))
- mhdr.Del(editor.name)
- }
- }
-
- part, err := reader.NextPart()
- if err != nil {
- return errors.Wrap(err, "reader.NextPart")
- }
- c.PrependContents(part.Body)
-
- var (
- headers string
- fds = mhdr.Fields()
- )
- for fds.Next() {
- headers += fmt.Sprintf("%s: %s\n", fds.Key(), fds.Value())
- }
- if headers != "" {
- headers += "\n"
- }
-
- c.PrependContents(bytes.NewReader([]byte(headers)))
+ c.PrependContents(bytes.NewReader(templateText))
return nil
}