diff --git a/app/Console/Commands/FetchEmails.php b/app/Console/Commands/FetchEmails.php index 675f2ecb..7c8ca30a 100644 --- a/app/Console/Commands/FetchEmails.php +++ b/app/Console/Commands/FetchEmails.php @@ -153,12 +153,15 @@ class FetchEmails extends Command // } } + $unseen = \Eventy::filter('fetch_emails.unseen', $this->option('unseen'), $mailbox); + $this->line('['.date('Y-m-d H:i:s').'] Fetching: '.($unseen ? 'UNREAD' : 'ALL')); + foreach ($folders as $folder) { $this->line('['.date('Y-m-d H:i:s').'] Folder: '.$folder->name); // Get unseen messages for a period $messages = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread(); - if ($this->option('unseen')) { + if ($unseen) { $messages->unseen(); } if ($no_charset) { @@ -173,7 +176,7 @@ class FetchEmails extends Command // Solution for MS mailboxes. // https://github.com/freescout-helpdesk/freescout/issues/176 $messages = $folder->query()->since(now()->subDays($this->option('days')))->leaveUnread()->setCharset(null); - if ($this->option('unseen')) { + if ($unseen) { $messages->unseen(); } $messages = $messages->get();