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

message: Implement service layer, stubs for #81

I've made some effort to wire the manager into the controllers, but
tests are currently failing.
This commit is contained in:
James Hillyerd
2018-03-11 22:25:21 -07:00
parent 3bc66d2788
commit 10bc07a18e
14 changed files with 291 additions and 111 deletions

View File

@@ -99,22 +99,6 @@ func (m *Message) rawPath() string {
return filepath.Join(m.mailbox.path, m.Fid+".raw")
}
// ReadHeader opens the .raw portion of a Message and returns a standard Go mail.Message object
func (m *Message) ReadHeader() (msg *mail.Message, err error) {
file, err := os.Open(m.rawPath())
if err != nil {
return nil, err
}
defer func() {
if err := file.Close(); err != nil {
log.Errorf("Failed to close %q: %v", m.rawPath(), err)
}
}()
reader := bufio.NewReader(file)
return mail.ReadMessage(reader)
}
// ReadBody opens the .raw portion of a Message and returns a MIMEBody object
func (m *Message) ReadBody() (body *enmime.Envelope, err error) {
file, err := os.Open(m.rawPath())