mirror of
https://github.com/tiennm99/coolify.git
synced 2026-09-20 04:23:16 +00:00
Merge pull request #6837 from coollabsio/andrasbacsai/custom-webhooks
feat: add custom webhook notification support
This commit is contained in:
29 files changed
+889
No files matched your search
@@ -66,4 +66,19 @@ class DockerCleanupFailed extends CustomEmailNotification
|
||||
color: SlackMessage::errorColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
$url = base_url().'/server/'.$this->server->uuid;
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Docker cleanup job failed',
|
||||
'event' => 'docker_cleanup_failed',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'error_message' => $this->message,
|
||||
'url' => $url,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -66,4 +66,19 @@ class DockerCleanupSuccess extends CustomEmailNotification
|
||||
color: SlackMessage::successColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
$url = base_url().'/server/'.$this->server->uuid;
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Docker cleanup job succeeded',
|
||||
'event' => 'docker_cleanup_success',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'cleanup_message' => $this->message,
|
||||
'url' => $url,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -88,4 +88,18 @@ class HighDiskUsage extends CustomEmailNotification
|
||||
color: SlackMessage::errorColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'High disk usage detected',
|
||||
'event' => 'high_disk_usage',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'disk_usage' => $this->disk_usage,
|
||||
'threshold' => $this->server_disk_usage_notification_threshold,
|
||||
'url' => base_url().'/server/'.$this->server->uuid,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -74,4 +74,18 @@ class Reachable extends CustomEmailNotification
|
||||
color: SlackMessage::successColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
$url = base_url().'/server/'.$this->server->uuid;
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'message' => 'Server revived',
|
||||
'event' => 'server_reachable',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'url' => $url,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -345,4 +345,47 @@ class ServerPatchCheck extends CustomEmailNotification
|
||||
color: SlackMessage::errorColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
// Handle error case
|
||||
if (isset($this->patchData['error'])) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Failed to check patches',
|
||||
'event' => 'server_patch_check_error',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'os_id' => $this->patchData['osId'] ?? 'unknown',
|
||||
'package_manager' => $this->patchData['package_manager'] ?? 'unknown',
|
||||
'error' => $this->patchData['error'],
|
||||
'url' => $this->serverUrl,
|
||||
];
|
||||
}
|
||||
|
||||
$totalUpdates = $this->patchData['total_updates'] ?? 0;
|
||||
$updates = $this->patchData['updates'] ?? [];
|
||||
|
||||
// Check for critical packages
|
||||
$criticalPackages = collect($updates)->filter(function ($update) {
|
||||
return str_contains(strtolower($update['package']), 'docker') ||
|
||||
str_contains(strtolower($update['package']), 'kernel') ||
|
||||
str_contains(strtolower($update['package']), 'openssh') ||
|
||||
str_contains(strtolower($update['package']), 'ssl');
|
||||
});
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Server patches available',
|
||||
'event' => 'server_patch_check',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'total_updates' => $totalUpdates,
|
||||
'os_id' => $this->patchData['osId'] ?? 'unknown',
|
||||
'package_manager' => $this->patchData['package_manager'] ?? 'unknown',
|
||||
'updates' => $updates,
|
||||
'critical_packages_count' => $criticalPackages->count(),
|
||||
'url' => $this->serverUrl,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -82,4 +82,18 @@ class Unreachable extends CustomEmailNotification
|
||||
color: SlackMessage::errorColor()
|
||||
);
|
||||
}
|
||||
|
||||
public function toWebhook(): array
|
||||
{
|
||||
$url = base_url().'/server/'.$this->server->uuid;
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Server unreachable',
|
||||
'event' => 'server_unreachable',
|
||||
'server_name' => $this->server->name,
|
||||
'server_uuid' => $this->server->uuid,
|
||||
'url' => $url,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user