imap: ListMessages: handle body viewing, etc
This commit is contained in:
@@ -2,6 +2,7 @@ package store
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/mail"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -50,6 +51,15 @@ func (m *Maildir) NextUID() uint64 {
|
||||
return m.uids.NextUID()
|
||||
}
|
||||
|
||||
func (m *Maildir) MessageData(message Message) (io.ReadCloser, error) {
|
||||
filename, err := m.filesystem.Filename(message.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return os.Open(filename)
|
||||
}
|
||||
|
||||
func (c *concrete) CreateMaildir(m *Maildir) error {
|
||||
if m.directory == "" {
|
||||
m.directory = c.buildMaildirPath(m.Account, m.Name)
|
||||
|
@@ -9,12 +9,18 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type MessageInterface interface {
|
||||
CreateMessage(Message) error
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Maildir Maildir // maildir.name
|
||||
|
||||
UID uint64
|
||||
SeqNum uint64
|
||||
Key string
|
||||
UID uint64
|
||||
SeqNum uint64
|
||||
Key string
|
||||
|
||||
// Data is usually nil, but may be an io.ReadCloser if SetupData is called
|
||||
Data io.ReadCloser
|
||||
hdrCache mail.Header
|
||||
}
|
||||
@@ -54,10 +60,6 @@ func (m *Message) HeaderString() (string, error) {
|
||||
return sb.String(), nil // FIXME
|
||||
}
|
||||
|
||||
type MessageInterface interface {
|
||||
CreateMessage(Message) error
|
||||
}
|
||||
|
||||
// DeliverMessage takes the given message and delivers it to the correct maildir
|
||||
// It does not call Close() on message.Data
|
||||
func (c *concrete) CreateMessage(message Message) error {
|
||||
|
Reference in New Issue
Block a user