|
|
|
|
@ -31,6 +31,9 @@ class CameraMonitorSyncCommand extends Command
|
|
|
|
|
$health = $camera->health ?: $camera->health()->firstOrCreate([]);
|
|
|
|
|
$status = (string) ($r['healthStatus'] ?? ($r['pushStatus'] ?? ($r['sdkStatus'] ?? 'UNKNOWN')));
|
|
|
|
|
$health->fill(['status' => $status, 'sdk_status' => $r['sdkStatus'] ?? null, 'tcp_reachable' => $r['tcpReachable'] ?? null, 'last_pdc_at' => $r['lastPdcAt'] ?? null, 'pdc_count' => $r['pdcCount'] ?? 0, 'push_age_seconds' => (($r['pushAgeSeconds'] ?? -1) >= 0 ? $r['pushAgeSeconds'] : null), 'last_tcp_error' => $r['networkReason'] ?? null, 'reconnect_attempts' => $r['autoReconnectFailures'] ?? 0, 'observed_at' => now()])->save();
|
|
|
|
|
if (($r['sdkStatus'] ?? null) === 'ONLINE' && ($r['pushStatus'] ?? null) === 'ONLINE_PUSHING' && $camera->venue_id) {
|
|
|
|
|
CameraAlert::query()->where('venue_id', $camera->venue_id)->whereIn('status', ['OPEN', 'ACKNOWLEDGED'])->update(['status' => 'RESOLVED', 'recovered_at' => now()]);
|
|
|
|
|
}
|
|
|
|
|
$abnormal = in_array($status, ['NETWORK_DOWN', 'LOGIN_FAILED', 'ARM_FAILED', 'PUSH_STALE', 'NO_PUSH_YET', 'PUSH_SUSPECT'], true);
|
|
|
|
|
if (! $abnormal) return;
|
|
|
|
|
$needsManual = (bool) ($r['manualActionRequired'] ?? false);
|
|
|
|
|
|