-
Notifications
You must be signed in to change notification settings - Fork 4
/
server_mailstore.go
52 lines (44 loc) · 1.54 KB
/
server_mailstore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2014 The imapsrv Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the imapsrv.LICENSE file.
package imap
// A service that is needed to read mail messages
type Mailstore interface {
// Get IMAP mailbox information
// Returns nil if the mailbox does not exist
GetMailbox(name string) (*Mailbox, error)
// Get the sequence number of the first unseen message
FirstUnseen(mbox int64) (int64, error)
// Get the total number of messages in an IMAP mailbox
TotalMessages(mbox int64) (int64, error)
// Get the total number of unread messages in an IMAP mailbox
RecentMessages(mbox int64) (int64, error)
// Get the next available uid in an IMAP mailbox
NextUid(mbox int64) (int64, error)
}
// A dummy mailstore used for demonstrating the IMAP server
type DummyMailstore struct {
}
// Get mailbox information
func (m *DummyMailstore) GetMailbox(name string) (*Mailbox, error) {
return &Mailbox{
Name: "inbox",
Id: 1,
}, nil
}
// Get the sequence number of the first unseen message
func (m *DummyMailstore) FirstUnseen(mbox int64) (int64, error) {
return 4, nil
}
// Get the total number of messages in an IMAP mailbox
func (m *DummyMailstore) TotalMessages(mbox int64) (int64, error) {
return 8, nil
}
// Get the total number of unread messages in an IMAP mailbox
func (m *DummyMailstore) RecentMessages(mbox int64) (int64, error) {
return 4, nil
}
// Get the next available uid in an IMAP mailbox
func (m *DummyMailstore) NextUid(mbox int64) (int64, error) {
return 9, nil
}