@@ -20,7 +20,7 @@ class WatchMailbox extends Command
2020 *
2121 * @var string
2222 */
23- protected $ signature = 'imap:watch {mailbox} {folder?} {--with=} {--timeout=30} {--attempts=5} {--debug=false} ' ;
23+ protected $ signature = 'imap:watch {mailbox} {folder?} {--method=idle} {-- with=} {--timeout=30} {--attempts=5} {--debug=false} ' ;
2424
2525 /**
2626 * The console command description.
@@ -48,11 +48,18 @@ public function handle(LoopInterface $loop): void
4848 try {
4949 $ folder = $ this ->folder ($ mailbox );
5050
51- $ folder ->idle (
52- new HandleMessageReceived ($ this , $ attempts , $ lastReceivedAt ),
53- new ConfigureIdleQuery ($ with ),
54- $ this ->option ('timeout ' )
55- );
51+ match ($ this ->option ('method ' )) {
52+ 'idle ' => $ folder ->idle (
53+ new HandleMessageReceived ($ this , $ attempts , $ lastReceivedAt ),
54+ new ConfigureIdleQuery ($ with ),
55+ $ this ->option ('timeout ' ),
56+ ),
57+ 'poll ' => $ folder ->poll (
58+ new HandleMessageReceived ($ this , $ attempts , $ lastReceivedAt ),
59+ new ConfigureIdleQuery ($ with ),
60+ $ this ->option ('timeout ' ),
61+ ),
62+ };
5663 } catch (Exception $ e ) {
5764 if ($ this ->isMessageMissing ($ e )) {
5865 return ;
0 commit comments