mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
manager: Add MailboxForAddress(), calls policy pkg #84
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/jhillyerd/enmime"
|
||||
"github.com/jhillyerd/inbucket/pkg/policy"
|
||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||
)
|
||||
|
||||
@@ -14,6 +15,7 @@ type Manager interface {
|
||||
PurgeMessages(mailbox string) error
|
||||
RemoveMessage(mailbox, id string) error
|
||||
SourceReader(mailbox, id string) (io.ReadCloser, error)
|
||||
MailboxForAddress(address string) (string, error)
|
||||
}
|
||||
|
||||
// StoreManager is a message Manager backed by the storage.Store.
|
||||
@@ -72,6 +74,11 @@ func (s *StoreManager) SourceReader(mailbox, id string) (io.ReadCloser, error) {
|
||||
return sm.RawReader()
|
||||
}
|
||||
|
||||
// MailboxForAddress parses an email address to return the canonical mailbox name.
|
||||
func (s *StoreManager) MailboxForAddress(mailbox string) (string, error) {
|
||||
return policy.ParseMailboxName(mailbox)
|
||||
}
|
||||
|
||||
// makeMetadata populates Metadata from a StoreMessage.
|
||||
func makeMetadata(m storage.StoreMessage) *Metadata {
|
||||
return &Metadata{
|
||||
|
||||
Reference in New Issue
Block a user