From c4159d895ac399ca55326f7b4ff8bfbf8402e654 Mon Sep 17 00:00:00 2001 From: Jordan Date: Sat, 4 Feb 2023 23:54:03 -0700 Subject: initial commit --- .../github.com/emersion/go-imap/commands/delete.go | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 vendor/github.com/emersion/go-imap/commands/delete.go (limited to 'vendor/github.com/emersion/go-imap/commands/delete.go') diff --git a/vendor/github.com/emersion/go-imap/commands/delete.go b/vendor/github.com/emersion/go-imap/commands/delete.go new file mode 100644 index 0000000..60f4da8 --- /dev/null +++ b/vendor/github.com/emersion/go-imap/commands/delete.go @@ -0,0 +1,38 @@ +package commands + +import ( + "errors" + + "github.com/emersion/go-imap" + "github.com/emersion/go-imap/utf7" +) + +// Delete is a DELETE command, as defined in RFC 3501 section 6.3.3. +type Delete struct { + Mailbox string +} + +func (cmd *Delete) Command() *imap.Command { + mailbox, _ := utf7.Encoding.NewEncoder().String(cmd.Mailbox) + + return &imap.Command{ + Name: "DELETE", + Arguments: []interface{}{imap.FormatMailboxName(mailbox)}, + } +} + +func (cmd *Delete) Parse(fields []interface{}) error { + if len(fields) < 1 { + return errors.New("No enough arguments") + } + + if mailbox, err := imap.ParseString(fields[0]); err != nil { + return err + } else if mailbox, err := utf7.Encoding.NewDecoder().String(mailbox); err != nil { + return err + } else { + cmd.Mailbox = imap.CanonicalMailboxName(mailbox) + } + + return nil +} -- cgit v1.2.3-54-g00ecf