File tree Expand file tree Collapse file tree 1 file changed +27
-11
lines changed
Expand file tree Collapse file tree 1 file changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -261,21 +261,37 @@ protected function fetch(Collection $messages): array
261261 'desc ' => $ messages ->sortDesc (SORT_NUMERIC ),
262262 };
263263
264- $ uids = $ messages ->forPage ($ this ->page , $ this ->limit )
265- ->values ()
266- ->all ();
264+ $ uids = $ messages ->forPage ($ this ->page , $ this ->limit )->values ();
267265
268- $ response = $ this ->connection ()->fetch (array_filter ([
269- $ this ->fetchFlags ? 'FLAGS ' : null ,
270- $ this ->fetchBody ? $ this ->fetchAsUnread
266+ $ fetch = [];
267+
268+ if ($ this ->fetchFlags ) {
269+ $ fetch [] = 'FLAGS ' ;
270+ }
271+
272+ if ($ this ->fetchBody ) {
273+ $ fetch [] = $ this ->fetchAsUnread
271274 ? 'BODY.PEEK[TEXT] '
272- : 'BODY[TEXT] ' : null ,
273- $ this ->fetchHeaders ? $ this ->fetchAsUnread
275+ : 'BODY[TEXT] ' ;
276+ }
277+
278+ if ($ this ->fetchHeaders ) {
279+ $ fetch [] = $ this ->fetchAsUnread
274280 ? 'BODY.PEEK[HEADER] '
275- : 'BODY[HEADER] ' : null ,
276- ]), $ uids );
281+ : 'BODY[HEADER] ' ;
282+ }
283+
284+ if (empty ($ fetch )) {
285+ return $ uids ->mapWithKeys (fn (string |int $ uid ) => [
286+ $ uid => [
287+ 'flags ' => [],
288+ 'headers ' => '' ,
289+ 'contents ' => '' ,
290+ ],
291+ ])->all ();
292+ }
277293
278- return $ response ->mapWithKeys (function (UntaggedResponse $ response ) {
294+ return $ this -> connection ()-> fetch ( $ fetch , $ uids -> all ()) ->mapWithKeys (function (UntaggedResponse $ response ) {
279295 $ data = $ response ->tokenAt (3 );
280296
281297 $ uid = $ data ->lookup ('UID ' )->value ;
You can’t perform that action at this time.
0 commit comments