1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

Migrate from pkg go.enmime to enmime

This commit is contained in:
James Hillyerd
2016-11-17 18:35:01 -08:00
parent 145e71dc43
commit 1906a147f0
7 changed files with 19 additions and 19 deletions

View File

@@ -5,7 +5,7 @@ import (
"net/mail" "net/mail"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/smtpd" "github.com/jhillyerd/inbucket/smtpd"
"github.com/stretchr/testify/mock" "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) 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() 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) { func (m *MockMessage) ReadRaw() (raw *string, err error) {

View File

@@ -9,7 +9,7 @@ import (
"net/mail" "net/mail"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/config"
"github.com/jhillyerd/inbucket/httpd" "github.com/jhillyerd/inbucket/httpd"
"github.com/jhillyerd/inbucket/smtpd" "github.com/jhillyerd/inbucket/smtpd"
@@ -36,7 +36,7 @@ func (d *InputMessageData) MockMessage() *MockMessage {
Header: d.Header, Header: d.Header,
} }
msg.On("ReadHeader").Return(gomsg, nil) msg.On("ReadHeader").Return(gomsg, nil)
body := &enmime.MIMEBody{ body := &enmime.Envelope{
Text: d.Text, Text: d.Text,
HTML: d.HTML, HTML: d.HTML,
} }

View File

@@ -6,7 +6,7 @@ import (
"net/mail" "net/mail"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
) )
var ( var (
@@ -41,7 +41,7 @@ type Message interface {
Subject() string Subject() string
RawReader() (reader io.ReadCloser, err error) RawReader() (reader io.ReadCloser, err error)
ReadHeader() (msg *mail.Message, 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) ReadRaw() (raw *string, err error)
Append(data []byte) error Append(data []byte) error
Close() error Close() error

View File

@@ -12,7 +12,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/config"
"github.com/jhillyerd/inbucket/log" "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 // 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()) file, err := os.Open(m.rawPath())
if err != nil { if err != nil {
return nil, err return nil, err
@@ -401,7 +401,7 @@ func (m *FileMessage) ReadBody() (body *enmime.MIMEBody, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
mime, err := enmime.ParseMIMEBody(msg) mime, err := enmime.EnvelopeFromMessage(msg)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -7,7 +7,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
"github.com/stretchr/testify/mock" "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) 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() 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) { func (m *MockMessage) ReadRaw() (raw *string, err error) {

View File

@@ -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-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", "attachment") 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 err
} }
return nil return nil
@@ -387,7 +387,7 @@ func MailboxViewAttach(w http.ResponseWriter, req *http.Request, ctx *httpd.Cont
part := body.Attachments[num] part := body.Attachments[num]
w.Header().Set("Content-Type", part.ContentType()) 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 err
} }
return nil return nil

View File

@@ -13,7 +13,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/jhillyerd/go.enmime" "github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/config" "github.com/jhillyerd/inbucket/config"
"github.com/jhillyerd/inbucket/httpd" "github.com/jhillyerd/inbucket/httpd"
"github.com/jhillyerd/inbucket/smtpd" "github.com/jhillyerd/inbucket/smtpd"
@@ -64,7 +64,7 @@ func (d *InputMessageData) MockMessage() *MockMessage {
Header: d.Header, Header: d.Header,
} }
msg.On("ReadHeader").Return(gomsg, nil) msg.On("ReadHeader").Return(gomsg, nil)
body := &enmime.MIMEBody{ body := &enmime.Envelope{
Text: d.Text, Text: d.Text,
HTML: d.HTML, 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) 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() 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) { func (m *MockMessage) ReadRaw() (raw *string, err error) {