-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.go
47 lines (38 loc) · 816 Bytes
/
commands.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
package metadata
import (
"strings"
"github.com/emersion/go-imap"
)
type GetMetadataCommand struct {
Mailbox string
Entries []string
Options *GetMetadataOptions
}
func (cmd *GetMetadataCommand) Command() *imap.Command {
args := []interface{}{
imap.FormatMailboxName(cmd.Mailbox),
imap.FormatStringList(cmd.Entries),
}
return &imap.Command{
Name: "GETMETADATA",
Arguments: args,
}
}
type SetMetadataCommand struct {
Mailbox string
Entries map[string]string
}
func (cmd *SetMetadataCommand) Command() *imap.Command {
var entries []interface{}
for k, v := range cmd.Entries {
entries = append(entries, k, strings.NewReader(v))
}
args := []interface{}{
imap.FormatMailboxName(cmd.Mailbox),
entries,
}
return &imap.Command{
Name: "SETMETADATA",
Arguments: args,
}
}