about summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorLeszek CimaƂa <ernierasta@zori.cz>2020-01-08 21:44:14 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-09 14:31:19 -0500
commitbf28e23933a9808820ef4855257accf4634068e9 (patch)
treed09d522d0f48d6f3e1013f5f7197e64636e51e99 /lib
parentda6fb1a1551767609e1d5a97631bdaffdc301f4c (diff)
downloadaerc-bf28e23933a9808820ef4855257accf4634068e9.tar.gz
create OriginalMail struct
Diffstat (limited to 'lib')
-rw-r--r--lib/templates/template.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/templates/template.go b/lib/templates/template.go
index 21f7b35..8a345d9 100644
--- a/lib/templates/template.go
+++ b/lib/templates/template.go
@@ -10,6 +10,7 @@ import (
 	"text/template"
 	"time"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"github.com/mitchellh/go-homedir"
 )
 
@@ -28,20 +29,23 @@ type TemplateData struct {
 
 func TestTemplateData() TemplateData {
 	defaults := map[string]string{
-		"To":           "John Doe <john@example.com>",
-		"Cc":           "Josh Doe <josh@example.com>",
-		"From":         "Jane Smith <jane@example.com>",
-		"Subject":      "This is only a test",
-		"OriginalText": "This is only a test text",
-		"OriginalFrom": "John Doe <john@example.com>",
-		"OriginalDate": time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		"To":      "John Doe <john@example.com>",
+		"Cc":      "Josh Doe <josh@example.com>",
+		"From":    "Jane Smith <jane@example.com>",
+		"Subject": "This is only a test",
 	}
 
-	return ParseTemplateData(defaults)
+	original := models.OriginalMail{
+		Date: time.Now().Format("Mon Jan 2, 2006 at 3:04 PM"),
+		From: "John Doe <john@example.com>",
+		Text: "This is only a test text",
+	}
+
+	return ParseTemplateData(defaults, original)
 }
 
-func ParseTemplateData(defaults map[string]string) TemplateData {
-	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", defaults["OriginalDate"])
+func ParseTemplateData(defaults map[string]string, original models.OriginalMail) TemplateData {
+	originalDate, _ := time.Parse("Mon Jan 2, 2006 at 3:04 PM", original.Date)
 	td := TemplateData{
 		To:           parseAddressList(defaults["To"]),
 		Cc:           parseAddressList(defaults["Cc"]),
@@ -49,8 +53,8 @@ func ParseTemplateData(defaults map[string]string) TemplateData {
 		From:         parseAddressList(defaults["From"]),
 		Date:         time.Now(),
 		Subject:      defaults["Subject"],
-		OriginalText: defaults["Original"],
-		OriginalFrom: parseAddressList(defaults["OriginalFrom"]),
+		OriginalText: original.Text,
+		OriginalFrom: parseAddressList(original.From),
 		OriginalDate: originalDate,
 	}
 	return td