feat(api): open incidents and notify channels when monitors go down
Results are evaluated as they arrive. Transitions open or resolve the monitor's incident and queue a notification per enabled channel in the same transaction; every API replica delivers the outbox with leases and exponential retries. Organizations manage webhook and email channels, can send test notifications and list incidents. Email requires UPTIME_SMTP_URL. Closes #14 Closes #15 Closes #16 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
01ef543e62
commit
5f42e3e650
12 files changed
+822
-13
No files matched your search
@@ -14,7 +14,9 @@ import (
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/requestid"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/schedule"
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/sealed"
|
||||
@@ -38,6 +40,8 @@ type Server struct {
|
||||
totp *auth.TOTPVerifier
|
||||
sso *sso.Client
|
||||
sched *schedule.Scheduler
|
||||
eval *evaluate.Evaluator
|
||||
smtp *notify.SMTP
|
||||
}
|
||||
|
||||
// Deps are the external resources a Server needs.
|
||||
@@ -50,9 +54,13 @@ type Deps struct {
|
||||
}
|
||||
|
||||
// New returns a Server. It does not register any routes; see Mount.
|
||||
// cfg must have passed Validate.
|
||||
func New(cfg config.API, d Deps) *Server {
|
||||
allowPrivate := cfg.SSOAllowPrivate()
|
||||
mail, _ := notify.ParseSMTP(cfg.SMTPURL)
|
||||
return &Server{
|
||||
eval: evaluate.New(d.Redis),
|
||||
smtp: mail,
|
||||
cfg: cfg,
|
||||
log: d.Log,
|
||||
db: d.DB,
|
||||
@@ -105,6 +113,14 @@ func (s *Server) Mount(r gin.IRouter) {
|
||||
org.PUT("/monitors/:id", can(authz.MonitorsWrite), s.updateMonitor)
|
||||
org.DELETE("/monitors/:id", can(authz.MonitorsWrite), s.deleteMonitor)
|
||||
|
||||
org.GET("/incidents", can(authz.IncidentsRead), s.listIncidents)
|
||||
|
||||
org.GET("/channels", can(authz.NotificationsRead), s.listChannels)
|
||||
org.POST("/channels", can(authz.NotificationsWrite), s.createChannel)
|
||||
org.PUT("/channels/:id", can(authz.NotificationsWrite), s.updateChannel)
|
||||
org.DELETE("/channels/:id", can(authz.NotificationsWrite), s.deleteChannel)
|
||||
org.POST("/channels/:id/test", can(authz.NotificationsWrite), s.testChannel)
|
||||
|
||||
org.GET("/sso", can(authz.OrgManage), s.listSSOProviders)
|
||||
org.POST("/sso", sessionOnly(), can(authz.OrgManage), s.createSSOProvider)
|
||||
org.PUT("/sso/:id", sessionOnly(), can(authz.OrgManage), s.updateSSOProvider)
|
||||
|
||||
Reference in new issue
Block a user