@@ -10,7 +10,7 @@ import (
10
10
)
11
11
12
12
func (c * Conn ) handleList (dec * imapwire.Decoder ) error {
13
- ref , pattern , options , returnRecent , err := readListCmd (dec )
13
+ ref , pattern , options , err := readListCmd (dec )
14
14
if err != nil {
15
15
return err
16
16
}
@@ -20,9 +20,8 @@ func (c *Conn) handleList(dec *imapwire.Decoder) error {
20
20
}
21
21
22
22
w := & ListWriter {
23
- conn : c ,
24
- options : options ,
25
- returnRecent : returnRecent ,
23
+ conn : c ,
24
+ options : options ,
26
25
}
27
26
return c .session .List (w , ref , pattern , options )
28
27
}
@@ -117,11 +116,11 @@ func (c *Conn) writeLSub(data *imap.ListData) error {
117
116
return enc .CRLF ()
118
117
}
119
118
120
- func readListCmd (dec * imapwire.Decoder ) (ref string , patterns []string , options * imap.ListOptions , returnRecent bool , err error ) {
119
+ func readListCmd (dec * imapwire.Decoder ) (ref string , patterns []string , options * imap.ListOptions , err error ) {
121
120
options = & imap.ListOptions {}
122
121
123
122
if ! dec .ExpectSP () {
124
- return "" , nil , nil , false , dec .Err ()
123
+ return "" , nil , nil , dec .Err ()
125
124
}
126
125
127
126
hasSelectOpts , err := dec .List (func () error {
@@ -142,14 +141,14 @@ func readListCmd(dec *imapwire.Decoder) (ref string, patterns []string, options
142
141
return nil
143
142
})
144
143
if err != nil {
145
- return "" , nil , nil , false , fmt .Errorf ("in list-select-opts: %w" , err )
144
+ return "" , nil , nil , fmt .Errorf ("in list-select-opts: %w" , err )
146
145
}
147
146
if hasSelectOpts && ! dec .ExpectSP () {
148
- return "" , nil , nil , false , dec .Err ()
147
+ return "" , nil , nil , dec .Err ()
149
148
}
150
149
151
150
if ! dec .ExpectMailbox (& ref ) || ! dec .ExpectSP () {
152
- return "" , nil , nil , false , dec .Err ()
151
+ return "" , nil , nil , dec .Err ()
153
152
}
154
153
155
154
hasPatterns , err := dec .List (func () error {
@@ -160,13 +159,13 @@ func readListCmd(dec *imapwire.Decoder) (ref string, patterns []string, options
160
159
return err
161
160
})
162
161
if err != nil {
163
- return "" , nil , nil , false , err
162
+ return "" , nil , nil , err
164
163
} else if hasPatterns && len (patterns ) == 0 {
165
- return "" , nil , nil , false , newClientBugError ("LIST-EXTENDED requires a non-empty parenthesized pattern list" )
164
+ return "" , nil , nil , newClientBugError ("LIST-EXTENDED requires a non-empty parenthesized pattern list" )
166
165
} else if ! hasPatterns {
167
166
pattern , err := readListMailbox (dec )
168
167
if err != nil {
169
- return "" , nil , nil , false , err
168
+ return "" , nil , nil , err
170
169
}
171
170
if pattern != "" {
172
171
patterns = append (patterns , pattern )
@@ -176,26 +175,26 @@ func readListCmd(dec *imapwire.Decoder) (ref string, patterns []string, options
176
175
if dec .SP () { // list-return-opts
177
176
var atom string
178
177
if ! dec .ExpectAtom (& atom ) || ! dec .Expect (strings .EqualFold (atom , "RETURN" ), "RETURN" ) || ! dec .ExpectSP () {
179
- return "" , nil , nil , false , dec .Err ()
178
+ return "" , nil , nil , dec .Err ()
180
179
}
181
180
182
181
err := dec .ExpectList (func () error {
183
- return readReturnOption (dec , options , & returnRecent )
182
+ return readReturnOption (dec , options )
184
183
})
185
184
if err != nil {
186
- return "" , nil , nil , false , fmt .Errorf ("in list-return-opts: %w" , err )
185
+ return "" , nil , nil , fmt .Errorf ("in list-return-opts: %w" , err )
187
186
}
188
187
}
189
188
190
189
if ! dec .ExpectCRLF () {
191
- return "" , nil , nil , false , dec .Err ()
190
+ return "" , nil , nil , dec .Err ()
192
191
}
193
192
194
193
if options .SelectRecursiveMatch && ! options .SelectSubscribed {
195
- return "" , nil , nil , false , newClientBugError ("The LIST RECURSIVEMATCH select option requires SUBSCRIBED" )
194
+ return "" , nil , nil , newClientBugError ("The LIST RECURSIVEMATCH select option requires SUBSCRIBED" )
196
195
}
197
196
198
- return ref , patterns , options , returnRecent , nil
197
+ return ref , patterns , options , nil
199
198
}
200
199
201
200
func readListMailbox (dec * imapwire.Decoder ) (string , error ) {
@@ -219,7 +218,7 @@ func isListChar(ch byte) bool {
219
218
}
220
219
}
221
220
222
- func readReturnOption (dec * imapwire.Decoder , options * imap.ListOptions , recent * bool ) error {
221
+ func readReturnOption (dec * imapwire.Decoder , options * imap.ListOptions ) error {
223
222
var name string
224
223
if ! dec .ExpectAtom (& name ) {
225
224
return dec .Err ()
@@ -236,11 +235,7 @@ func readReturnOption(dec *imapwire.Decoder, options *imap.ListOptions, recent *
236
235
}
237
236
options .ReturnStatus = new (imap.StatusOptions )
238
237
return dec .ExpectList (func () error {
239
- isRecent , err := readStatusItem (dec , options .ReturnStatus )
240
- if isRecent {
241
- * recent = true
242
- }
243
- return err
238
+ return readStatusItem (dec , options .ReturnStatus )
244
239
})
245
240
default :
246
241
return newClientBugError ("Unknown LIST RETURN options" )
@@ -250,10 +245,9 @@ func readReturnOption(dec *imapwire.Decoder, options *imap.ListOptions, recent *
250
245
251
246
// ListWriter writes LIST responses.
252
247
type ListWriter struct {
253
- conn * Conn
254
- options * imap.ListOptions
255
- returnRecent bool
256
- lsub bool
248
+ conn * Conn
249
+ options * imap.ListOptions
250
+ lsub bool
257
251
}
258
252
259
253
// WriteList writes a single LIST response for a mailbox.
@@ -266,7 +260,7 @@ func (w *ListWriter) WriteList(data *imap.ListData) error {
266
260
return err
267
261
}
268
262
if w .options .ReturnStatus != nil && data .Status != nil {
269
- if err := w .conn .writeStatus (data .Status , w .options .ReturnStatus , w . returnRecent ); err != nil {
263
+ if err := w .conn .writeStatus (data .Status , w .options .ReturnStatus ); err != nil {
270
264
return err
271
265
}
272
266
}
0 commit comments