1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 01:57:02 +00:00

storage: Add Seen flag, tests for #58

This commit is contained in:
James Hillyerd
2018-03-31 21:46:10 -07:00
parent e3be5362dc
commit cc5cd7f9c3
8 changed files with 100 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ type Message struct {
date time.Time
subject string
source []byte
seen bool
el *list.Element // This message in Store.messages
}
@@ -51,3 +52,6 @@ func (m *Message) Source() (io.ReadCloser, error) {
// Size returns the message size in bytes.
func (m *Message) Size() int64 { return int64(len(m.source)) }
// Seen returns the message seen flag.
func (m *Message) Seen() bool { return m.seen }

View File

@@ -112,6 +112,17 @@ func (s *Store) GetMessages(mailbox string) (ms []storage.Message, err error) {
return ms, err
}
// MarkSeen marks a message as having been read.
func (s *Store) MarkSeen(mailbox, id string) error {
s.withMailbox(mailbox, true, func(mb *mbox) {
m := mb.messages[id]
if m != nil {
m.seen = true
}
})
return nil
}
// PurgeMessages deletes the contents of a mailbox.
func (s *Store) PurgeMessages(mailbox string) error {
var messages map[string]*Message