From 1906a147f0db8c868b1a3f51ce8540cea4c6b3bd Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Thu, 17 Nov 2016 18:35:01 -0800 Subject: [PATCH] Migrate from pkg go.enmime to enmime --- rest/testmocks_test.go | 6 +++--- rest/testutils_test.go | 4 ++-- smtpd/datastore.go | 4 ++-- smtpd/filestore.go | 6 +++--- smtpd/retention_test.go | 6 +++--- webui/mailbox_controller.go | 4 ++-- webui/rest_test.go | 8 ++++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/rest/testmocks_test.go b/rest/testmocks_test.go index 30a46bf..a671165 100644 --- a/rest/testmocks_test.go +++ b/rest/testmocks_test.go @@ -5,7 +5,7 @@ import ( "net/mail" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" "github.com/jhillyerd/inbucket/smtpd" "github.com/stretchr/testify/mock" ) @@ -90,9 +90,9 @@ func (m *MockMessage) ReadHeader() (msg *mail.Message, err error) { return args.Get(0).(*mail.Message), args.Error(1) } -func (m *MockMessage) ReadBody() (body *enmime.MIMEBody, err error) { +func (m *MockMessage) ReadBody() (body *enmime.Envelope, err error) { args := m.Called() - return args.Get(0).(*enmime.MIMEBody), args.Error(1) + return args.Get(0).(*enmime.Envelope), args.Error(1) } func (m *MockMessage) ReadRaw() (raw *string, err error) { diff --git a/rest/testutils_test.go b/rest/testutils_test.go index 3d4f86d..1e98562 100644 --- a/rest/testutils_test.go +++ b/rest/testutils_test.go @@ -9,7 +9,7 @@ import ( "net/mail" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" "github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/httpd" "github.com/jhillyerd/inbucket/smtpd" @@ -36,7 +36,7 @@ func (d *InputMessageData) MockMessage() *MockMessage { Header: d.Header, } msg.On("ReadHeader").Return(gomsg, nil) - body := &enmime.MIMEBody{ + body := &enmime.Envelope{ Text: d.Text, HTML: d.HTML, } diff --git a/smtpd/datastore.go b/smtpd/datastore.go index 746be78..c06ad6a 100644 --- a/smtpd/datastore.go +++ b/smtpd/datastore.go @@ -6,7 +6,7 @@ import ( "net/mail" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" ) var ( @@ -41,7 +41,7 @@ type Message interface { Subject() string RawReader() (reader io.ReadCloser, err error) ReadHeader() (msg *mail.Message, err error) - ReadBody() (body *enmime.MIMEBody, err error) + ReadBody() (body *enmime.Envelope, err error) ReadRaw() (raw *string, err error) Append(data []byte) error Close() error diff --git a/smtpd/filestore.go b/smtpd/filestore.go index b40869f..91af5e3 100644 --- a/smtpd/filestore.go +++ b/smtpd/filestore.go @@ -12,7 +12,7 @@ import ( "sync" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" "github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/log" ) @@ -385,7 +385,7 @@ func (m *FileMessage) ReadHeader() (msg *mail.Message, err error) { } // ReadBody opens the .raw portion of a Message and returns a MIMEBody object -func (m *FileMessage) ReadBody() (body *enmime.MIMEBody, err error) { +func (m *FileMessage) ReadBody() (body *enmime.Envelope, err error) { file, err := os.Open(m.rawPath()) if err != nil { return nil, err @@ -401,7 +401,7 @@ func (m *FileMessage) ReadBody() (body *enmime.MIMEBody, err error) { if err != nil { return nil, err } - mime, err := enmime.ParseMIMEBody(msg) + mime, err := enmime.EnvelopeFromMessage(msg) if err != nil { return nil, err } diff --git a/smtpd/retention_test.go b/smtpd/retention_test.go index 1344498..95b17c1 100644 --- a/smtpd/retention_test.go +++ b/smtpd/retention_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" "github.com/stretchr/testify/mock" ) @@ -146,9 +146,9 @@ func (m *MockMessage) ReadHeader() (msg *mail.Message, err error) { return args.Get(0).(*mail.Message), args.Error(1) } -func (m *MockMessage) ReadBody() (body *enmime.MIMEBody, err error) { +func (m *MockMessage) ReadBody() (body *enmime.Envelope, err error) { args := m.Called() - return args.Get(0).(*enmime.MIMEBody), args.Error(1) + return args.Get(0).(*enmime.Envelope), args.Error(1) } func (m *MockMessage) ReadRaw() (raw *string, err error) { diff --git a/webui/mailbox_controller.go b/webui/mailbox_controller.go index 523a5c6..cadb226 100644 --- a/webui/mailbox_controller.go +++ b/webui/mailbox_controller.go @@ -337,7 +337,7 @@ func MailboxDownloadAttach(w http.ResponseWriter, req *http.Request, ctx *httpd. w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Disposition", "attachment") - if _, err := w.Write(part.Content()); err != nil { + if _, err := io.Copy(w, part); err != nil { return err } return nil @@ -387,7 +387,7 @@ func MailboxViewAttach(w http.ResponseWriter, req *http.Request, ctx *httpd.Cont part := body.Attachments[num] w.Header().Set("Content-Type", part.ContentType()) - if _, err := w.Write(part.Content()); err != nil { + if _, err := io.Copy(w, part); err != nil { return err } return nil diff --git a/webui/rest_test.go b/webui/rest_test.go index 0a1cd2c..5b6dd3a 100644 --- a/webui/rest_test.go +++ b/webui/rest_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/jhillyerd/go.enmime" + "github.com/jhillyerd/enmime" "github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/httpd" "github.com/jhillyerd/inbucket/smtpd" @@ -64,7 +64,7 @@ func (d *InputMessageData) MockMessage() *MockMessage { Header: d.Header, } msg.On("ReadHeader").Return(gomsg, nil) - body := &enmime.MIMEBody{ + body := &enmime.Envelope{ Text: d.Text, HTML: d.HTML, } @@ -498,9 +498,9 @@ func (m *MockMessage) ReadHeader() (msg *mail.Message, err error) { return args.Get(0).(*mail.Message), args.Error(1) } -func (m *MockMessage) ReadBody() (body *enmime.MIMEBody, err error) { +func (m *MockMessage) ReadBody() (body *enmime.Envelope, err error) { args := m.Called() - return args.Get(0).(*enmime.MIMEBody), args.Error(1) + return args.Get(0).(*enmime.Envelope), args.Error(1) } func (m *MockMessage) ReadRaw() (raw *string, err error) {