Skip to content

Commit

Permalink
fixup! Add imip processing
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Jul 19, 2022
1 parent 80482b1 commit f113610
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/Service/IMipService.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public function process() {
$account = $accounts[$mailbox->getAccountId()];
// mailbox not in collated array, maybe specal use?
// no processing for drafts and sent items
if ($mailbox->getSpecialUse() === '["sent"]' || $mailbox->getSpecialUse() === '["drafts"]') { // does this need more use cases? Also probably won't work? @todo
if ($mailbox->isSpecialUse("sent") || $mailbox->isSpecialUse("drafts")) { // does this need more use cases? Also probably won't work? @todo
$message->setImipProcessed(true); // Silently drop from passing to DAV and mark as processed, so we won't run into this message again.
$processedMessages[$account->getId()] = $message;
$processedMessages[$account->getId()][] = $message;
continue;
}

Expand All @@ -109,14 +109,14 @@ public function process() {
$imapMessage = $this->mailManager->getImapMessage($account, $mailbox, $message->getUid());
} catch (ServiceException $e) {
$message->setImipError(true);
$processedMessages[$account->getId()] = $message;
$processedMessages[$account->getId()][] = $message;
continue;
}

if (empty($imapMessage->scheduling)) {
// No scheduling info, maybe the DB is wrong
$message->setImipError(true);
$processedMessages[$account->getId()] = $message;
$processedMessages[$account->getId()][] = $message;
continue;
}

Expand All @@ -131,12 +131,15 @@ public function process() {
}
$message->setImipProcessed($processed);
$message->setImipError(!$processed);
$processedMessages[$account->getId()] = $message;
$processedMessages[$account->getId()][] = $message;
}

foreach ($processedMessages as $accountId => $messages) {
foreach ($accountIds as $accountId) {
if (!isset($processedMessages[$accountId])) {
continue;
}
try {
$this->messageMapper->updateBulk($accounts[$accountId], false, $messages);
$this->messageMapper->updateBulk($accounts[$accountId], false, $processedMessages[$accountId]);
} catch (\Throwable $e) {
$this->logger->error('Could not update iMip messages for account ' . $accountId, ['exception' => $e]);
}
Expand Down

0 comments on commit f113610

Please sign in to comment.