blob: 613a8706482d3bf9feb1d7e9c7d2958ba18fbec5 (
plain)
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
|
package commands
import (
"errors"
"github.com/emersion/go-imap"
"github.com/emersion/go-imap/utf7"
)
// A MOVE command.
// See RFC 6851 section 3.1.
type Move struct {
SeqSet *imap.SeqSet
Mailbox string
}
func (cmd *Move) Command() *imap.Command {
mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox)
return &imap.Command{
Name: "MOVE",
Arguments: []interface{}{cmd.SeqSet, mailbox},
}
}
func (cmd *Move) Parse(fields []interface{}) (err error) {
if len(fields) < 2 {
return errors.New("No enough arguments")
}
seqset, ok := fields[0].(string)
if !ok {
return errors.New("Invalid sequence set")
}
if cmd.SeqSet, err = imap.ParseSeqSet(seqset); err != nil {
return err
}
mailbox, ok := fields[1].(string)
if !ok {
return errors.New("Mailbox name must be a string")
}
if cmd.Mailbox, err = utf7.Encoding.NewDecoder().String(mailbox); err != nil {
return err
}
return
}
|