fedi-feed-router/app/Services/SystemStatusService.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2025-07-10 11:06:17 +02:00
<?php
namespace App\Services;
use App\Models\Feed;
use App\Models\FeedPlatformChannel;
use App\Models\PlatformChannel;
use App\Models\Setting;
class SystemStatusService
{
public function getSystemStatus(): array
{
$reasons = [];
$isEnabled = true;
if (!Setting::isArticleProcessingEnabled()) {
$isEnabled = false;
$reasons[] = 'Manually disabled by user';
}
if (!Feed::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active feeds configured';
}
if (!PlatformChannel::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active platform channels configured';
}
if (!FeedPlatformChannel::where('is_active', true)->exists()) {
$isEnabled = false;
$reasons[] = 'No active feed-to-channel routes configured';
}
return [
'is_enabled' => $isEnabled,
'status' => $isEnabled ? 'Enabled' : 'Disabled',
'status_class' => $isEnabled ? 'text-green-600' : 'text-red-600',
'reasons' => $reasons,
];
}
public function canProcessArticles(): bool
{
return $this->getSystemStatus()['is_enabled'];
}
}