From 124f830478d7861d6ba36eeb4d04aabf93b92a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wojtun=CC=81?= Date: Thu, 1 Sep 2016 15:01:34 +0200 Subject: [PATCH] Added "To:" header --- rest/apiv1_controller.go | 4 ++++ smtpd/datastore.go | 1 + smtpd/filestore.go | 9 +++++++++ themes/bootstrap/templates/mailbox/_show.html | 2 ++ themes/integral/templates/mailbox/_show.html | 4 ++++ webui/mailbox_controller.go | 3 +++ 6 files changed, 23 insertions(+) diff --git a/rest/apiv1_controller.go b/rest/apiv1_controller.go index 365b838..452600a 100644 --- a/rest/apiv1_controller.go +++ b/rest/apiv1_controller.go @@ -17,6 +17,7 @@ type JSONMessageHeaderV1 struct { Mailbox string `json:"mailbox"` ID string `json:"id"` From string `json:"from"` + To string `json:"to"` Subject string `json:"subject"` Date time.Time `json:"date"` Size int64 `json:"size"` @@ -27,6 +28,7 @@ type JSONMessageV1 struct { Mailbox string `json:"mailbox"` ID string `json:"id"` From string `json:"from"` + To string `json:"to"` Subject string `json:"subject"` Date time.Time `json:"date"` Size int64 `json:"size"` @@ -65,6 +67,7 @@ func MailboxListV1(w http.ResponseWriter, req *http.Request, ctx *httpd.Context) Mailbox: name, ID: msg.ID(), From: msg.From(), + To: msg.To(), Subject: msg.Subject(), Date: msg.Date(), Size: msg.Size(), @@ -109,6 +112,7 @@ func MailboxShowV1(w http.ResponseWriter, req *http.Request, ctx *httpd.Context) Mailbox: name, ID: msg.ID(), From: msg.From(), + To: msg.To(), Subject: msg.Subject(), Date: msg.Date(), Size: msg.Size(), diff --git a/smtpd/datastore.go b/smtpd/datastore.go index ea1256d..a483852 100644 --- a/smtpd/datastore.go +++ b/smtpd/datastore.go @@ -36,6 +36,7 @@ type Mailbox interface { type Message interface { ID() string From() string + To() string Date() time.Time Subject() string RawReader() (reader io.ReadCloser, err error) diff --git a/smtpd/filestore.go b/smtpd/filestore.go index dc46141..a17c5e1 100644 --- a/smtpd/filestore.go +++ b/smtpd/filestore.go @@ -295,6 +295,7 @@ type FileMessage struct { Fid string Fdate time.Time Ffrom string + Fto string Fsubject string Fsize int64 // These are for creating new messages only @@ -343,6 +344,13 @@ func (m *FileMessage) From() string { return m.Ffrom } + +// From returns the value of the Message From header +func (m *FileMessage) To() string { + return m.Fto +} + + // Subject returns the value of the Message Subject header func (m *FileMessage) Subject() string { return m.Fsubject @@ -486,6 +494,7 @@ func (m *FileMessage) Close() error { // Only public fields are stored in gob m.Ffrom = body.GetHeader("From") + m.Fto = body.GetHeader("To") m.Fsubject = body.GetHeader("Subject") // Refresh the index before adding our message diff --git a/themes/bootstrap/templates/mailbox/_show.html b/themes/bootstrap/templates/mailbox/_show.html index 3825e5c..ada6fd8 100644 --- a/themes/bootstrap/templates/mailbox/_show.html +++ b/themes/bootstrap/templates/mailbox/_show.html @@ -52,6 +52,8 @@
From:
{{.message.From}}
+
To:
+
{{.message.To}}
Date:
{{.message.Date}}
Subject:
diff --git a/themes/integral/templates/mailbox/_show.html b/themes/integral/templates/mailbox/_show.html index 6dbaf3d..e5313db 100644 --- a/themes/integral/templates/mailbox/_show.html +++ b/themes/integral/templates/mailbox/_show.html @@ -13,6 +13,10 @@ From: {{.message.From}} + + To: + {{.message.To}} + Date: {{.message.Date}} diff --git a/webui/mailbox_controller.go b/webui/mailbox_controller.go index 523a5c6..6166260 100644 --- a/webui/mailbox_controller.go +++ b/webui/mailbox_controller.go @@ -19,6 +19,7 @@ type JSONMessageHeader struct { Mailbox string ID string `json:"Id"` From string + To string Subject string Date time.Time Size int64 @@ -29,6 +30,7 @@ type JSONMessage struct { Mailbox string ID string `json:"Id"` From string + To string Subject string Date time.Time Size int64 @@ -113,6 +115,7 @@ func MailboxList(w http.ResponseWriter, req *http.Request, ctx *httpd.Context) ( Mailbox: name, ID: msg.ID(), From: msg.From(), + To: msg.To(), Subject: msg.Subject(), Date: msg.Date(), Size: msg.Size(),