Skip to content

Commit 08b95f8

Browse files
committed
Merge client support for ENABLE extension
1 parent c7dce92 commit 08b95f8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ includes:
135135
* [CHILDREN](https://tools.ietf.org/html/rfc3348)
136136
* [UNSELECT](https://tools.ietf.org/html/rfc3691)
137137
* [APPENDLIMIT](https://tools.ietf.org/html/rfc7889)
138+
* [ENABLE](https://tools.ietf.org/html/rfc5161)
138139

139140
Support for other extensions is provided via separate packages. See below.
140141

@@ -147,7 +148,6 @@ wiki](https://github.com/emersion/go-imap/wiki/Using-extensions#using-client-ext
147148
to learn how to use them.
148149

149150
* [COMPRESS](https://github.com/emersion/go-imap-compress)
150-
* [ENABLE](https://github.com/emersion/go-imap-enable)
151151
* [ID](https://github.com/ProtonMail/go-imap-id)
152152
* [IDLE](https://github.com/emersion/go-imap-idle)
153153
* [METADATA](https://github.com/emersion/go-imap-metadata)

client/cmd_auth.go

+24
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,27 @@ func (c *Client) Append(mbox string, flags []string, date time.Time, msg imap.Li
252252
}
253253
return status.Err()
254254
}
255+
256+
// Enable requests the server to enable the named extensions. The extensions
257+
// which were successfully enabled are returned.
258+
//
259+
// See RFC 5161 section 3.1.
260+
func (c *Client) Enable(caps []string) ([]string, error) {
261+
if ok, err := c.Support("ENABLE"); !ok || err != nil {
262+
return nil, ErrExtensionUnsupported
263+
}
264+
265+
// ENABLE is invalid if a mailbox has been selected.
266+
if c.State() != imap.AuthenticatedState {
267+
return nil, ErrNotLoggedIn
268+
}
269+
270+
cmd := &commands.Enable{Caps: caps}
271+
res := &responses.Enabled{}
272+
273+
if status, err := c.Execute(cmd, res); err != nil {
274+
return nil, err
275+
} else {
276+
return res.Caps, status.Err()
277+
}
278+
}

0 commit comments

Comments
 (0)