1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 11:22:42 +01:00

fetch emails hook unseen

This commit is contained in:
Tillmann Baumgart 2020-12-23 08:16:57 +01:00
parent c6fa18fe8d
commit 1fc7c4d53d

View File

@ -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();