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

Merge pull request #959 from tillmon/unseen

Fetch emails hook unseen
This commit is contained in:
FreeScout 2020-12-24 08:45:27 +03:00 committed by GitHub
commit 3140c2e90c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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