mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 18:24:35 +03:00
fix the Status command on imapclient.Conn
it needs at least 1 attribute. also make types for those attributes, so its harder to get them wrong. nothing was using this function.
This commit is contained in:
@ -206,10 +206,15 @@ func (c *Conn) Namespace() (untagged []Untagged, result Result, rerr error) {
|
||||
return c.Transactf("namespace")
|
||||
}
|
||||
|
||||
// Status requests information about a mailbox, such as number of messages, size, etc.
|
||||
func (c *Conn) Status(mailbox string) (untagged []Untagged, result Result, rerr error) {
|
||||
// Status requests information about a mailbox, such as number of messages, size,
|
||||
// etc. At least one attribute required.
|
||||
func (c *Conn) Status(mailbox string, attrs ...StatusAttr) (untagged []Untagged, result Result, rerr error) {
|
||||
defer c.recover(&rerr)
|
||||
return c.Transactf("status %s", astring(mailbox))
|
||||
l := make([]string, len(attrs))
|
||||
for i, a := range attrs {
|
||||
l[i] = string(a)
|
||||
}
|
||||
return c.Transactf("status %s (%s)", astring(mailbox), strings.Join(l, " "))
|
||||
}
|
||||
|
||||
// Append adds message to mailbox with flags and optional receive time.
|
||||
|
@ -363,14 +363,14 @@ func (c *Conn) xuntagged() Untagged {
|
||||
mailbox := c.xastring()
|
||||
c.xspace()
|
||||
c.xtake("(")
|
||||
attrs := map[string]int64{}
|
||||
attrs := map[StatusAttr]int64{}
|
||||
for !c.take(')') {
|
||||
if len(attrs) > 0 {
|
||||
c.xspace()
|
||||
}
|
||||
s := c.xatom()
|
||||
c.xspace()
|
||||
S := strings.ToUpper(s)
|
||||
S := StatusAttr(strings.ToUpper(s))
|
||||
var num int64
|
||||
// ../rfc/9051:7059
|
||||
switch S {
|
||||
|
@ -224,8 +224,25 @@ type UntaggedSearchModSeq struct {
|
||||
}
|
||||
type UntaggedStatus struct {
|
||||
Mailbox string
|
||||
Attrs map[string]int64 // Upper case status attributes. ../rfc/9051:7059
|
||||
Attrs map[StatusAttr]int64 // Upper case status attributes.
|
||||
}
|
||||
|
||||
// ../rfc/9051:7059 ../9208:712
|
||||
type StatusAttr string
|
||||
|
||||
const (
|
||||
StatusMessages StatusAttr = "MESSAGES"
|
||||
StatusUIDNext StatusAttr = "UIDNEXT"
|
||||
StatusUIDValidity StatusAttr = "UIDVALIDITY"
|
||||
StatusUnseen StatusAttr = "UNSEEN"
|
||||
StatusDeleted StatusAttr = "DELETED"
|
||||
StatusSize StatusAttr = "SIZE"
|
||||
StatusRecent StatusAttr = "RECENT"
|
||||
StatusAppendLimit StatusAttr = "APPENDLIMIT"
|
||||
StatusHighestModSeq StatusAttr = "HIGHESTMODSEQ"
|
||||
StatusDeletedStorage StatusAttr = "DELETED-STORAGE"
|
||||
)
|
||||
|
||||
type UntaggedNamespace struct {
|
||||
Personal, Other, Shared []NamespaceDescr
|
||||
}
|
||||
|
Reference in New Issue
Block a user