Jobs setup

This commit is contained in:
2023-06-12 21:14:07 -04:00
parent 03c1dac2f2
commit 88f91c4bd5
60 changed files with 965 additions and 495 deletions

View File

@ -154,7 +154,6 @@ class Messages extends Base
$message->doesHaveValidAttachments();
}
}
error_log(json_encode(compact('message')).PHP_EOL,3,'/logs/debug');
$this->getRepository()->save($message);
return true;
} catch (PDOException $e) {
@ -196,20 +195,7 @@ class Messages extends Base
$registered = $this->getMailboxes()->getRegistered();
foreach ($registered as $mailbox) {
if (!$this->getMailboxes()->isUpdated($mailbox)) {
$this->logger->info("Updating messages from {$mailbox->getName()}");
$this->grab($mailbox->getName());
}
}
}
public function checkSchedule(): void
{
$messages = $this->getRepository()->fetchAll();
foreach ($messages as $message) {
if ($message->hasAttachments() and $message->hasValidAttachments() and !$message->hasDownloadedAttachments() and !$message->hasScheduledDownloads()) {
if ($this->getJobsService()->schedule($message->getId())) {
$message->doesHaveDownloadedAttachments();
$this->getRepository()->save($message);
}
$this->getJobsService()->queue('messages:grab', [$mailbox->getId()]);
}
}
}