Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jorikfon committed Apr 11, 2024
1 parent 58e2ae4 commit 0816d1f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Core/Workers/WorkerNotifyError.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
namespace MikoPBX\Core\Workers;
require_once 'Globals.php';

use MikoPBX\Common\Handlers\CriticalErrorsHandler;
use MikoPBX\Common\Providers\ManagedCacheProvider;
use MikoPBX\Core\System\Notifications;
use MikoPBX\PBXCoreREST\Lib\AdvicesProcessor;
use Throwable;

/**
* WorkerNotifyError is a worker class responsible for checking the significant advices messages and sent it to system administrator.
Expand All @@ -45,19 +47,22 @@ public function start(array $argv): void
// Retrieve the last error check timestamp from the cache
$lastErrorsCheck = $managedCache->get($cacheKey);
if ($lastErrorsCheck === null) {
$restResponse = AdvicesProcessor::callBack(['action' => 'getList']);
$errorMessages = $restResponse->data['advices']['error']??[];
if ($restResponse->success and $errorMessages!==[]) {
Notifications::sendAdminNotification('adv_ThereIsSomeTroublesWithMikoPBX', $errorMessages);
try {
$restResponse = AdvicesProcessor::callBack(['action' => 'getList']);
$errorMessages = $restResponse->data['advices']['error'] ?? [];
if ($restResponse->success and $errorMessages !== []) {
Notifications::sendAdminNotification('adv_ThereIsSomeTroublesWithMikoPBX', $errorMessages);
}
// Store the current timestamp in the cache to track the last error check
$managedCache->set($cacheKey, time(), 3600); // Check every hour
} catch (Throwable $exception) {
CriticalErrorsHandler::handleExceptionWithSyslog($exception);
}

// Store the current timestamp in the cache to track the last error check
$managedCache->set($cacheKey, time(), 3600); // Check every hour
}

}

}

// Start worker process
// Start a worker process
WorkerNotifyError::startWorker($argv ?? []);

0 comments on commit 0816d1f

Please sign in to comment.