aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/emersion/go-imap/commands/move.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/emersion/go-imap/commands/move.go')
-rw-r--r--vendor/github.com/emersion/go-imap/commands/move.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/github.com/emersion/go-imap/commands/move.go b/vendor/github.com/emersion/go-imap/commands/move.go
new file mode 100644
index 0000000..613a870
--- /dev/null
+++ b/vendor/github.com/emersion/go-imap/commands/move.go
@@ -0,0 +1,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
+}