|
|
|
|
@ -29,7 +29,7 @@ class CameraMonitorSyncCommand extends Command
|
|
|
|
|
$r = $byKey->get(trim($camera->ip).'#'.(int) $camera->channel);
|
|
|
|
|
if (! $r) return;
|
|
|
|
|
$health = $camera->health ?: $camera->health()->firstOrCreate([]);
|
|
|
|
|
$status = (string) ($r['pushStatus'] ?? ($r['sdkStatus'] ?? 'UNKNOWN'));
|
|
|
|
|
$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), 'reconnect_attempts' => $r['autoReconnectFailures'] ?? 0, 'observed_at' => now()])->save();
|
|
|
|
|
if (! ($r['manualActionRequired'] ?? false) || ! $camera->notification_enabled || ! $settings->send_manual_action_email) return;
|
|
|
|
|
$alert = CameraAlert::query()->where('camera_device_id', $camera->id)->where('alert_type', 'MANUAL_ACTION_REQUIRED')->whereIn('status', ['OPEN','ACKNOWLEDGED'])->latest('id')->first();
|
|
|
|
|
|