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

storage: More refactoring for #69

- impl Store.AddMessage
- file: Use AddMessage() in tests
- smtp: Switch to AddMessage
- storage: Remove NewMessage, Append, Close methods
This commit is contained in:
James Hillyerd
2018-03-13 22:00:44 -07:00
parent 9be4eec31c
commit 2cc0da3093
10 changed files with 208 additions and 208 deletions

View File

@@ -2,10 +2,13 @@
package message
import (
"io"
"io/ioutil"
"net/mail"
"time"
"github.com/jhillyerd/enmime"
"github.com/jhillyerd/inbucket/pkg/storage"
)
// Metadata holds information about a message, but not the content.
@@ -24,3 +27,51 @@ type Message struct {
Metadata
Envelope *enmime.Envelope
}
// Delivery is used to add a message to storage.
type Delivery struct {
Meta Metadata
Reader io.Reader
}
var _ storage.StoreMessage = &Delivery{}
// Mailbox getter.
func (d *Delivery) Mailbox() string {
return d.Meta.Mailbox
}
// ID getter.
func (d *Delivery) ID() string {
return d.Meta.ID
}
// From getter.
func (d *Delivery) From() *mail.Address {
return d.Meta.From
}
// To getter.
func (d *Delivery) To() []*mail.Address {
return d.Meta.To
}
// Date getter.
func (d *Delivery) Date() time.Time {
return d.Meta.Date
}
// Subject getter.
func (d *Delivery) Subject() string {
return d.Meta.Subject
}
// Size getter.
func (d *Delivery) Size() int64 {
return d.Meta.Size
}
// RawReader contains the raw content of the message.
func (d *Delivery) RawReader() (io.ReadCloser, error) {
return ioutil.NopCloser(d.Reader), nil
}