From eef662c60677355b47b8903c619b742c1a91d3d6 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 4 Dec 2019 09:49:53 -0500 Subject: Revert "Parse headers from template" This reverts commit 31e3e9f56e0b8123f0238537112496b407055aef. --- widgets/compose.go | 42 +++--------------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) (limited to 'widgets') diff --git a/widgets/compose.go b/widgets/compose.go index 6e527cb..62aaafe 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 } -- cgit 1.4.1-2-gfad0
path: root/build
blob: 9e95bb342a2e10fe6442bc935ab03349d81b75eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109