aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/emersion/go-imap/commands/uid.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/emersion/go-imap/commands/uid.go')
-rw-r--r--vendor/github.com/emersion/go-imap/commands/uid.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/emersion/go-imap/commands/uid.go b/vendor/github.com/emersion/go-imap/commands/uid.go
new file mode 100644
index 0000000..979af14
--- /dev/null
+++ b/vendor/github.com/emersion/go-imap/commands/uid.go
@@ -0,0 +1,44 @@
+package commands
+
+import (
+ "errors"
+ "strings"
+
+ "github.com/emersion/go-imap"
+)
+
+// Uid is a UID command, as defined in RFC 3501 section 6.4.8. It wraps another
+// command (e.g. wrapping a Fetch command will result in a UID FETCH).
+type Uid struct {
+ Cmd imap.Commander
+}
+
+func (cmd *Uid) Command() *imap.Command {
+ inner := cmd.Cmd.Command()
+
+ args := []interface{}{imap.RawString(inner.Name)}
+ args = append(args, inner.Arguments...)
+
+ return &imap.Command{
+ Name: "UID",
+ Arguments: args,
+ }
+}
+
+func (cmd *Uid) Parse(fields []interface{}) error {
+ if len(fields) < 0 {
+ return errors.New("No command name specified")
+ }
+
+ name, ok := fields[0].(string)
+ if !ok {
+ return errors.New("Command name must be a string")
+ }
+
+ cmd.Cmd = &imap.Command{
+ Name: strings.ToUpper(name), // Command names are case-insensitive
+ Arguments: fields[1:],
+ }
+
+ return nil
+}