coolify/app/Jobs/NotifyOutdatedTraefikServersJob.php
Andras Bacsai 6dbe58f22b feat(proxy): enhance Traefik version notifications to show patch and minor upgrades
- Store both patch update and newer minor version information simultaneously
- Display patch update availability alongside minor version upgrades in notifications
- Add newer_branch_target and newer_branch_latest fields to traefik_outdated_info
- Update all notification channels (Discord, Telegram, Slack, Pushover, Email, Webhook)
- Show minor version in format (e.g., v3.6) for upgrade targets instead of patch version
- Enhance UI callouts with clearer messaging about available upgrades
- Remove verbose logging in favor of cleaner code structure
- Handle edge case where SSH command returns empty response

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 14:53:49 +01:00

68 lines
1.9 KiB
PHP

<?php
namespace App\Jobs;
use App\Enums\ProxyTypes;
use App\Models\Server;
use App\Models\Team;
use App\Notifications\Server\TraefikVersionOutdated;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class NotifyOutdatedTraefikServersJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3;
/**
* Create a new job instance.
*/
public function __construct()
{
$this->onQueue('high');
}
/**
* Execute the job.
*/
public function handle(): void
{
// Query servers that have outdated info stored
$servers = Server::whereNotNull('proxy')
->whereProxyType(ProxyTypes::TRAEFIK->value)
->whereRelation('settings', 'is_reachable', true)
->whereRelation('settings', 'is_usable', true)
->get();
$outdatedServers = collect();
foreach ($servers as $server) {
if ($server->traefik_outdated_info) {
// Attach the outdated info as a dynamic property for the notification
$server->outdatedInfo = $server->traefik_outdated_info;
$outdatedServers->push($server);
}
}
if ($outdatedServers->isEmpty()) {
return;
}
// Group by team and send notifications
$serversByTeam = $outdatedServers->groupBy('team_id');
foreach ($serversByTeam as $teamId => $teamServers) {
$team = Team::find($teamId);
if (! $team) {
continue;
}
// Send one notification per team with all outdated servers
$team->notify(new TraefikVersionOutdated($teamServers));
}
}
}