feat: notification channels for chat, push and paging services
ci / image (pull_request) Successful in 3m1s
ci / test (pull_request) Successful in 6m17s
ci / build (pull_request) Successful in 8m47s
ci / lint (pull_request) Successful in 9m36s

Channels of the new types store their settings with secrets sealed and
bound to type and field, never return them, and keep them when an update
leaves them empty. Messages are rendered in the channel's language with
a link to the monitor. The channels page offers every service with its
fields.

Closes #92

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 16:07:24 +01:00
1 parent a0a67ec5f8
commit b01eefdbce
12 files changed
+1114 -134

No files matched your search

+7
View File
@@ -217,6 +217,13 @@ func (s *Server) send(ctx context.Context, typ string, config []byte, ev notify.
} }
return s.smtp.Send(ctx, s.mailFor(ev, c.To, c.Locale)) return s.smtp.Send(ctx, s.mailFor(ev, c.To, c.Locale))
} }
if p, ok := notify.Lookup(typ); ok {
settings, locale, err := s.openProviderSettings(typ, config)
if err != nil {
return err
}
return p.Send(ctx, settings, s.messageFor(ev, locale), !s.cloud())
}
return fmt.Errorf("unknown channel type %q", typ) return fmt.Errorf("unknown channel type %q", typ)
} }
+3 -2
View File
@@ -121,8 +121,9 @@ var endpoints = []endpoint{
{method: "GET", path: "/api/v1/org/channels", tag: "Alerting", summary: "List notification channels", perm: "notifications.read", {method: "GET", path: "/api/v1/org/channels", tag: "Alerting", summary: "List notification channels", perm: "notifications.read",
resp: obj{"channels": []channelView{}, "email_available": false}}, resp: obj{"channels": []channelView{}, "email_available": false}},
{method: "POST", path: "/api/v1/org/channels", tag: "Alerting", summary: "Create a channel", {method: "POST", path: "/api/v1/org/channels", tag: "Alerting", summary: "Create a channel",
description: "Webhook channels return their signing secret once.", perm: "notifications.write", description: "`type` is webhook (`url`), email (`to`, `locale`) or one of slack, discord, teams, googlechat, mattermost, rocketchat, telegram, matrix, ntfy, gotify, pushover, pushbullet, signal, pagerduty, opsgenie, apprise with their `settings`. Secret settings are stored encrypted and never returned; on update, leaving one empty keeps it. Webhook channels return their signing secret once.",
req: channelRequest{}, status: http.StatusCreated, resp: obj{"channel": channelView{}, "signing_secret": ""}}, perm: "notifications.write",
req: channelRequest{}, status: http.StatusCreated, resp: obj{"channel": channelView{}, "signing_secret": ""}},
{method: "PUT", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Change a channel", perm: "notifications.write", {method: "PUT", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Change a channel", perm: "notifications.write",
req: channelRequest{}, resp: obj{"channel": channelView{}, "signing_secret": ""}}, req: channelRequest{}, resp: obj{"channel": channelView{}, "signing_secret": ""}},
{method: "DELETE", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Delete a channel", perm: "notifications.write", {method: "DELETE", path: "/api/v1/org/channels/:id", tag: "Alerting", summary: "Delete a channel", perm: "notifications.write",
+14 -1
View File
@@ -22,11 +22,14 @@ import (
type channelRequest struct { type channelRequest struct {
Name string `json:"name" binding:"required,max=100"` Name string `json:"name" binding:"required,max=100"`
Type string `json:"type" binding:"required,oneof=webhook email"` Type string `json:"type" binding:"required,max=32"`
URL string `json:"url" binding:"max=2000"` URL string `json:"url" binding:"max=2000"`
To []string `json:"to" binding:"max=20,dive,max=320"` To []string `json:"to" binding:"max=20,dive,max=320"`
Locale string `json:"locale" binding:"max=10"` Locale string `json:"locale" binding:"max=10"`
Enabled *bool `json:"enabled"` Enabled *bool `json:"enabled"`
// Settings configure the other channel types, as listed by
// notify.Providers; secret settings left empty keep their value.
Settings map[string]string `json:"settings" binding:"max=20"`
} }
type channelView struct { type channelView struct {
@@ -37,6 +40,10 @@ type channelView struct {
URL string `json:"url,omitempty"` URL string `json:"url,omitempty"`
To []string `json:"to,omitempty"` To []string `json:"to,omitempty"`
Locale string `json:"locale,omitempty"` Locale string `json:"locale,omitempty"`
// Settings and SecretsSet describe other channel types; secret values
// are never returned.
Settings map[string]string `json:"settings,omitempty"`
SecretsSet []string `json:"secrets_set,omitempty"`
} }
func viewChannel(ch store.NotificationChannel) channelView { func viewChannel(ch store.NotificationChannel) channelView {
@@ -50,6 +57,8 @@ func viewChannel(ch store.NotificationChannel) channelView {
var c emailConfig var c emailConfig
_ = json.Unmarshal(ch.Config, &c) _ = json.Unmarshal(ch.Config, &c)
v.To, v.Locale = c.To, c.Locale v.To, v.Locale = c.To, c.Locale
default:
v.Settings, v.SecretsSet, v.Locale = providerView(ch.Config)
} }
return v return v
} }
@@ -109,6 +118,10 @@ func (s *Server) channelConfig(req *channelRequest, previous []byte) (config []b
config, _ = json.Marshal(emailConfig{To: req.To, Locale: req.Locale}) config, _ = json.Marshal(emailConfig{To: req.To, Locale: req.Locale})
return config, "", "" return config, "", ""
} }
if p, ok := notify.Lookup(req.Type); ok {
config, code = s.providerSettings(p, req, previous)
return config, "", code
}
return nil, "", "invalid_input" return nil, "", "invalid_input"
} }
+25
View File
@@ -21,6 +21,7 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/check" "git.zb-server.de/ZB-Server/uptimesebi/internal/check"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/maintenance" "git.zb-server.de/ZB-Server/uptimesebi/internal/maintenance"
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store" "git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/web" "git.zb-server.de/ZB-Server/uptimesebi/internal/web"
) )
@@ -663,12 +664,36 @@ func (s *Server) channelsView(c *gin.Context, p *principal, page web.Page, me we
return nil, err return nil, err
} }
v := web.ChannelsView{EmailAvailable: s.smtp != nil, CanWrite: p.Grants.Can(authz.NotificationsWrite), Languages: s.catalog.Supported()} v := web.ChannelsView{EmailAvailable: s.smtp != nil, CanWrite: p.Grants.Can(authz.NotificationsWrite), Languages: s.catalog.Supported()}
ctx2 := c.Request.Context()
for _, pr := range notify.Providers {
opt := web.ProviderOption{Type: pr.Type}
if help := i18n.T(ctx2, "channels.help_"+pr.Type); help != "channels.help_"+pr.Type {
opt.Help = help
}
for _, f := range pr.Fields {
opt.Fields = append(opt.Fields, web.ProviderField{
Name: f.Name, Label: i18n.T(ctx2, "channels.field_"+f.Name), Required: f.Required, Secret: f.Secret,
Kind: f.Kind, Options: f.Options, Default: f.Default,
})
}
v.Providers = append(v.Providers, opt)
}
for _, r := range rows { for _, r := range rows {
cv := viewChannel(r) cv := viewChannel(r)
target := cv.URL target := cv.URL
if cv.Type == "email" { if cv.Type == "email" {
target = strings.Join(cv.To, ", ") target = strings.Join(cv.To, ", ")
} }
// Other services show their first setting that is no secret, such
// as the chat, topic or server.
if p, ok := notify.Lookup(cv.Type); ok {
for _, f := range p.Fields {
if v, ok := cv.Settings[f.Name]; ok && !f.Secret {
target = v
break
}
}
}
v.Channels = append(v.Channels, web.ChannelRow{ID: r.ID.String(), Name: r.Name, Type: r.Type, Target: target, Enabled: r.Enabled}) v.Channels = append(v.Channels, web.ChannelRow{ID: r.ID.String(), Name: r.Name, Type: r.Type, Target: target, Enabled: r.Enabled})
} }
return web.ChannelsPage(page, me, v), nil return web.ChannelsPage(page, me, v), nil
+158
View File
@@ -0,0 +1,158 @@
package api
import (
"encoding/base64"
"encoding/json"
"net/url"
"slices"
"strconv"
"strings"
"time"
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
)
// providerConfig is stored for channels of notify.Providers. Secret
// settings are sealed, bound to the channel type and field, and never
// shown again.
type providerConfig struct {
Settings map[string]string `json:"settings"`
Sealed map[string]string `json:"sealed"`
Locale string `json:"locale"`
}
func secretAAD(typ, field string) []byte { return []byte("channel:" + typ + ":" + field) }
// providerSettings validates the settings of a provider channel. Secret
// fields left empty keep their previous value, so a form can be saved
// without asking for tokens again.
func (s *Server) providerSettings(p notify.Provider, req *channelRequest, previous []byte) ([]byte, string) {
var old providerConfig
if previous != nil {
_ = json.Unmarshal(previous, &old)
}
cfg := providerConfig{Settings: map[string]string{}, Sealed: map[string]string{}, Locale: req.Locale}
for _, f := range p.Fields {
v := strings.TrimSpace(req.Settings[f.Name])
if f.Secret {
if v == "" {
if sealed, ok := old.Sealed[f.Name]; ok {
cfg.Sealed[f.Name] = sealed
continue
}
if f.Required {
return nil, "invalid_channel_settings"
}
continue
}
} else if v == "" {
v = f.Default
}
if v == "" {
if f.Required {
return nil, "invalid_channel_settings"
}
continue
}
if len(v) > 2000 || !s.validSetting(f, v) {
return nil, "invalid_channel_settings"
}
if f.Secret {
cfg.Sealed[f.Name] = base64.StdEncoding.EncodeToString(s.keys.Seal([]byte(v), secretAAD(p.Type, f.Name)))
} else {
cfg.Settings[f.Name] = v
}
}
if cfg.Locale == "" || !s.catalog.IsSupported(cfg.Locale) {
cfg.Locale = "en"
}
raw, _ := json.Marshal(cfg)
return raw, ""
}
func (s *Server) validSetting(f notify.Field, v string) bool {
switch f.Kind {
case "url":
u, err := url.Parse(v)
// Plain http only where services may live on private networks.
return err == nil && u.Host != "" && u.User == nil && (u.Scheme == "https" || (u.Scheme == "http" && !s.cloud()))
case "number":
_, err := strconv.Atoi(v)
return err == nil
case "select":
return slices.Contains(f.Options, v)
}
return !strings.ContainsAny(v, "\r\n")
}
// providerView shows the settings of a provider channel; secrets appear
// only as the names of fields that are set.
func providerView(raw []byte) (map[string]string, []string, string) {
var cfg providerConfig
_ = json.Unmarshal(raw, &cfg)
set := make([]string, 0, len(cfg.Sealed))
for k := range cfg.Sealed {
set = append(set, k)
}
slices.Sort(set)
if cfg.Settings == nil {
cfg.Settings = map[string]string{}
}
return cfg.Settings, set, cfg.Locale
}
// openProviderSettings returns all settings with secrets unsealed.
func (s *Server) openProviderSettings(typ string, raw []byte) (map[string]string, string, error) {
var cfg providerConfig
if err := json.Unmarshal(raw, &cfg); err != nil {
return nil, "", err
}
out := map[string]string{}
for k, v := range cfg.Settings {
out[k] = v
}
for k, v := range cfg.Sealed {
sealed, err := base64.StdEncoding.DecodeString(v)
if err != nil {
return nil, "", err
}
plain, err := s.keys.Open(sealed, secretAAD(typ, k))
if err != nil {
return nil, "", err
}
out[k] = string(plain)
}
return out, cfg.Locale, nil
}
// messageFor renders an event for chat and push services in locale.
func (s *Server) messageFor(ev notify.Event, locale string) notify.Message {
l := s.catalog.Match(locale)
data := map[string]any{"Monitor": ev.Monitor.Name}
m := notify.Message{Event: ev.Kind, Key: ev.IncidentID}
var lines []string
switch ev.Kind {
case notify.Opened:
m.Title = l.T("notify.title_opened", data)
for region, msg := range ev.Cause {
lines = append(lines, region+": "+msg)
}
slices.Sort(lines)
case notify.Resolved:
m.Title = l.T("notify.title_resolved", data)
if ev.ResolvedAt != nil {
lines = append(lines, l.T("notify.duration", map[string]any{"Duration": ev.ResolvedAt.Sub(ev.StartedAt).Round(time.Second).String()}))
}
default:
m.Title = l.T("notify.title_test", data)
lines = append(lines, l.T("notify.test_body", nil))
}
if ev.Monitor.Target != "" && ev.Monitor.Type != "heartbeat" {
lines = append([]string{ev.Monitor.Type + " · " + ev.Monitor.Target}, lines...)
}
m.Body = strings.Join(lines, "\n")
if ev.Monitor.ID != [16]byte{} {
m.URL = strings.TrimSuffix(s.cfg.PublicURL, "/") + "/monitors/" + ev.Monitor.ID.String()
}
return m
}
+105
View File
@@ -0,0 +1,105 @@
package api_test
import (
"context"
"io"
"net/http"
"net/http/httptest"
"strings"
"sync"
"testing"
"github.com/jackc/pgx/v5"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
)
func TestProvidersAreTranslated(t *testing.T) {
catalog, err := i18n.Load()
if err != nil {
t.Fatal(err)
}
for _, lang := range catalog.Supported() {
ctx := i18n.NewContext(context.Background(), catalog.Match(lang))
for _, p := range notify.Providers {
ids := []string{"channels.type_" + p.Type}
for _, f := range p.Fields {
ids = append(ids, "channels.field_"+f.Name)
}
for _, id := range ids {
if i18n.T(ctx, id) == id {
t.Errorf("%s: %s is not translated", lang, id)
}
}
}
}
}
func TestProviderChannel(t *testing.T) {
e := newEnv(t)
var mu sync.Mutex
var paths, bodies []string
telegram := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, _ := io.ReadAll(r.Body)
mu.Lock()
paths, bodies = append(paths, r.URL.Path), append(bodies, string(b))
mu.Unlock()
}))
defer telegram.Close()
owner := e.browser(t)
owner.signup("o@"+uniq("pr")+".test", uniq("pr-"))
st, body := owner.do("POST", "/api/v1/org/channels", map[string]any{"name": "Ops chat", "type": "telegram", "settings": map[string]string{"chat_id": "-100"}})
expect(t, "missing bot token", st, body, http.StatusUnprocessableEntity, "invalid_channel_settings")
st, body = owner.do("POST", "/api/v1/org/channels", map[string]any{"name": "x", "type": "carrierpigeon"})
expect(t, "unknown type", st, body, http.StatusUnprocessableEntity, "invalid_input")
st, body = owner.do("POST", "/api/v1/org/channels", map[string]any{
"name": "Ops chat", "type": "telegram", "locale": "de",
"settings": map[string]string{"bot_token": "4711:very-secret", "chat_id": "-100123", "api_url": telegram.URL},
})
if st != http.StatusCreated {
t.Fatalf("create telegram channel = %d %v", st, body)
}
ch := body["channel"].(map[string]any)
id := ch["id"].(string)
if raw := mustJSON(body); strings.Contains(raw, "very-secret") || ch["settings"].(map[string]any)["chat_id"] != "-100123" ||
mustJSON(ch["secrets_set"]) != `["bot_token"]` {
t.Errorf("create answer = %s", raw)
}
var stored string
_ = e.asSystem(t, func(tx pgx.Tx) error {
return tx.QueryRow(context.Background(), `SELECT config::text FROM notification_channels WHERE id = $1`, id).Scan(&stored)
})
if strings.Contains(stored, "very-secret") {
t.Error("the bot token is stored in plain text")
}
if _, list := owner.do("GET", "/api/v1/org/channels", nil); strings.Contains(mustJSON(list), "very-secret") {
t.Error("the channel list shows the bot token")
}
if st, body := owner.do("POST", "/api/v1/org/channels/"+id+"/test", nil); st != http.StatusNoContent {
t.Fatalf("test send = %d %v", st, body)
}
// Saving without the token keeps it.
st, body = owner.do("PUT", "/api/v1/org/channels/"+id, map[string]any{
"name": "Ops chat", "type": "telegram", "locale": "de",
"settings": map[string]string{"chat_id": "-100999", "api_url": telegram.URL},
})
if st != http.StatusOK {
t.Fatalf("update = %d %v", st, body)
}
owner.do("POST", "/api/v1/org/channels/"+id+"/test", nil)
mu.Lock()
defer mu.Unlock()
if len(paths) != 2 || paths[0] != "/bot4711:very-secret/sendMessage" || paths[1] != paths[0] {
t.Errorf("telegram requests = %v", paths)
}
if !strings.Contains(bodies[0], "Test von UptimeSebi") || !strings.Contains(bodies[1], `"chat_id":"-100999"`) {
t.Errorf("telegram bodies = %v", bodies)
}
if _, _, page := owner.page("/settings/channels"); !strings.Contains(page, `name="settings.bot_token"`) || !strings.Contains(page, "-100999") {
t.Error("the channels page lacks the service form or the channel")
}
}
+2 -1
View File
@@ -153,7 +153,7 @@ func TestDynamicFamilies(t *testing.T) {
families := map[string][]string{ families := map[string][]string{
"status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"}, "status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"},
"monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "heartbeat", "alertmanager"}, "monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "heartbeat", "alertmanager"},
"channels.type_": {"webhook", "email"}, "channels.type_": {"webhook", "email", "slack", "discord", "teams", "googlechat", "mattermost", "rocketchat", "telegram", "matrix", "ntfy", "gotify", "pushover", "pushbullet", "signal", "pagerduty", "opsgenie", "apprise"},
"agents.kind_": {"checker", "statuspage"}, "agents.kind_": {"checker", "statuspage"},
"page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"}, "page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"},
"page.component.": {"operational", "degraded", "outage", "unknown", "maintenance"}, "page.component.": {"operational", "degraded", "outage", "unknown", "maintenance"},
@@ -162,6 +162,7 @@ func TestDynamicFamilies(t *testing.T) {
"monitors.op_": {"eq", "ne", "gt", "ge", "lt", "le", "contains", "exists", "absent"}, "monitors.op_": {"eq", "ne", "gt", "ge", "lt", "le", "contains", "exists", "absent"},
"evidence.stage_": {"dns", "connect", "tls", "response", "body"}, "evidence.stage_": {"dns", "connect", "tls", "response", "body"},
"evidence.phase_": {"dns", "connect", "tls", "wait", "download"}, "evidence.phase_": {"dns", "connect", "tls", "wait", "download"},
"channels.field_": {"webhook_url", "channel", "bot_token", "chat_id", "thread_id", "api_url", "homeserver_url", "access_token", "room_id", "server_url", "topic", "priority", "app_token", "user_key", "device", "number", "recipients", "routing_key", "severity", "api_key", "region", "urls", "config_key"},
"weekday.": {"0", "1", "2", "3", "4", "5", "6"}, "weekday.": {"0", "1", "2", "3", "4", "5", "6"},
"md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"}, "md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"},
"maintenance.recurrence_": {"none", "daily", "weekly", "monthly"}, "maintenance.recurrence_": {"none", "daily", "weekly", "monthly"},
+55
View File
@@ -112,16 +112,65 @@
"auth.sso.submit": "Weiter", "auth.sso.submit": "Weiter",
"channels.create": "Kanal anlegen", "channels.create": "Kanal anlegen",
"channels.delete_confirm": "Diesen Kanal löschen?", "channels.delete_confirm": "Diesen Kanal löschen?",
"channels.field_access_token": "Zugriffstoken",
"channels.field_api_key": "API-Schlüssel",
"channels.field_api_url": "API-URL",
"channels.field_app_token": "Anwendungs-Token",
"channels.field_bot_token": "Bot-Token",
"channels.field_channel": "Kanal",
"channels.field_chat_id": "Chat-ID",
"channels.field_config_key": "Konfigurationsschlüssel",
"channels.field_device": "Gerät",
"channels.field_homeserver_url": "Homeserver-URL",
"channels.field_number": "Absendernummer",
"channels.field_priority": "Priorität",
"channels.field_recipients": "Empfänger (durch Komma getrennt)",
"channels.field_region": "Region",
"channels.field_room_id": "Raum-ID",
"channels.field_routing_key": "Integrationsschlüssel",
"channels.field_server_url": "Server-URL",
"channels.field_severity": "Schweregrad",
"channels.field_thread_id": "Themen-ID (Forum-Gruppen)",
"channels.field_topic": "Topic",
"channels.field_urls": "Apprise-URLs",
"channels.field_user_key": "Benutzer-Schlüssel",
"channels.field_webhook_url": "Webhook-URL",
"channels.help_apprise": "Erreicht über 100 Dienste über einen Apprise-API-Server: gib Apprise-URLs oder den Schlüssel einer dort gespeicherten Konfiguration an.",
"channels.help_opsgenie": "Der Alert wird geschlossen, wenn der Vorfall behoben ist.",
"channels.help_pagerduty": "Nutze den Integrationsschlüssel einer Events-API-v2-Integration; die Behebung schließt den PagerDuty-Vorfall.",
"channels.help_signal": "Braucht einen signal-cli-REST-API-Server (bbernhard/signal-cli-rest-api) mit registrierter Nummer.",
"channels.help_teams": "Nutze die URL eines Teams-Workflows „Bei Empfang einer Webhookanforderung in einem Kanal posten“.",
"channels.help_telegram": "Lege mit @BotFather einen Bot an; die Chat-ID einer Gruppe beginnt mit -100.",
"channels.intro": "Jeder aktive Kanal wird benachrichtigt, wenn ein Monitor in allen seinen Regionen ausfällt und wenn er sich erholt.", "channels.intro": "Jeder aktive Kanal wird benachrichtigt, wenn ein Monitor in allen seinen Regionen ausfällt und wenn er sich erholt.",
"channels.language": "Sprache", "channels.language": "Sprache",
"channels.new_email": "Neuer E-Mail-Kanal", "channels.new_email": "Neuer E-Mail-Kanal",
"channels.new_service": "Weitere Dienste",
"channels.new_webhook": "Neuer Webhook", "channels.new_webhook": "Neuer Webhook",
"channels.optional": "optional",
"channels.secret_now": "Signatur-Secret: Prüfe damit den Header X-Uptimesebi-Signature. Es wird nicht erneut angezeigt.", "channels.secret_now": "Signatur-Secret: Prüfe damit den Header X-Uptimesebi-Signature. Es wird nicht erneut angezeigt.",
"channels.service": "Dienst",
"channels.service_intro": "Chat-, Push- und Alarmierungsdienste. Tokens und Schlüssel werden verschlüsselt gespeichert und nie wieder angezeigt.",
"channels.test": "Test senden", "channels.test": "Test senden",
"channels.test_ok": "Testbenachrichtigung zugestellt.", "channels.test_ok": "Testbenachrichtigung zugestellt.",
"channels.title": "Benachrichtigungen", "channels.title": "Benachrichtigungen",
"channels.to": "Empfänger", "channels.to": "Empfänger",
"channels.type_apprise": "Apprise",
"channels.type_discord": "Discord",
"channels.type_email": "E-Mail", "channels.type_email": "E-Mail",
"channels.type_googlechat": "Google Chat",
"channels.type_gotify": "Gotify",
"channels.type_matrix": "Matrix",
"channels.type_mattermost": "Mattermost",
"channels.type_ntfy": "ntfy",
"channels.type_opsgenie": "Opsgenie",
"channels.type_pagerduty": "PagerDuty",
"channels.type_pushbullet": "Pushbullet",
"channels.type_pushover": "Pushover",
"channels.type_rocketchat": "Rocket.Chat",
"channels.type_signal": "Signal",
"channels.type_slack": "Slack",
"channels.type_teams": "Microsoft Teams",
"channels.type_telegram": "Telegram",
"channels.type_webhook": "Webhook", "channels.type_webhook": "Webhook",
"channels.url": "Webhook-URL", "channels.url": "Webhook-URL",
"checkers.avg_latency": "Mittlere Latenz", "checkers.avg_latency": "Mittlere Latenz",
@@ -189,6 +238,7 @@
"error.invalid_assertion_path": "Ein Pfad ist ungültig. Nutze durch Punkte getrennte Schlüssel und [n] für Array-Elemente.", "error.invalid_assertion_path": "Ein Pfad ist ungültig. Nutze durch Punkte getrennte Schlüssel und [n] für Array-Elemente.",
"error.invalid_assertion_value": "Vergleiche mit <, >, ≤ und ≥ brauchen eine Zahl.", "error.invalid_assertion_value": "Vergleiche mit <, >, ≤ und ≥ brauchen eine Zahl.",
"error.invalid_assertions": "Lege 1 bis 10 Bedingungen an.", "error.invalid_assertions": "Lege 1 bis 10 Bedingungen an.",
"error.invalid_channel_settings": "Fülle die Pflichtfelder aus; Adressen müssen https-URLs sein.",
"error.invalid_code": "Code ungültig.", "error.invalid_code": "Code ungültig.",
"error.invalid_config": "Die Check-Einstellungen sind ungültig.", "error.invalid_config": "Die Check-Einstellungen sind ungültig.",
"error.invalid_credentials": "E-Mail oder Passwort falsch.", "error.invalid_credentials": "E-Mail oder Passwort falsch.",
@@ -595,6 +645,11 @@
"monitors.type_tls": "TLS-Zertifikat", "monitors.type_tls": "TLS-Zertifikat",
"monitors.uptime_chart": "Uptime pro Zeitraum", "monitors.uptime_chart": "Uptime pro Zeitraum",
"monitors.verify_tls": "TLS-Zertifikat prüfen", "monitors.verify_tls": "TLS-Zertifikat prüfen",
"notify.duration": "Ausgefallen für {{.Duration}}",
"notify.test_body": "Wenn du das lesen kannst, funktioniert der Kanal.",
"notify.title_opened": "{{.Monitor}} ist ausgefallen",
"notify.title_resolved": "{{.Monitor}} ist wieder erreichbar",
"notify.title_test": "Test von UptimeSebi",
"org.policy": "Anmelderichtlinie", "org.policy": "Anmelderichtlinie",
"org.require_sso": "SSO verlangen", "org.require_sso": "SSO verlangen",
"org.require_sso_hint": "Mitglieder müssen sich über den Identity Provider dieser Organisation anmelden. Der Owner kann weiterhin ein Passwort nutzen, damit ein defekter IdP euch nicht aussperrt.", "org.require_sso_hint": "Mitglieder müssen sich über den Identity Provider dieser Organisation anmelden. Der Owner kann weiterhin ein Passwort nutzen, damit ein defekter IdP euch nicht aussperrt.",
+55
View File
@@ -112,16 +112,65 @@
"auth.sso.submit": "Continue", "auth.sso.submit": "Continue",
"channels.create": "Create channel", "channels.create": "Create channel",
"channels.delete_confirm": "Delete this channel?", "channels.delete_confirm": "Delete this channel?",
"channels.field_access_token": "Access token",
"channels.field_api_key": "API key",
"channels.field_api_url": "API URL",
"channels.field_app_token": "Application token",
"channels.field_bot_token": "Bot token",
"channels.field_channel": "Channel",
"channels.field_chat_id": "Chat ID",
"channels.field_config_key": "Configuration key",
"channels.field_device": "Device",
"channels.field_homeserver_url": "Homeserver URL",
"channels.field_number": "Sender number",
"channels.field_priority": "Priority",
"channels.field_recipients": "Recipients (comma-separated)",
"channels.field_region": "Region",
"channels.field_room_id": "Room ID",
"channels.field_routing_key": "Integration key",
"channels.field_server_url": "Server URL",
"channels.field_severity": "Severity",
"channels.field_thread_id": "Topic ID (forum groups)",
"channels.field_topic": "Topic",
"channels.field_urls": "Apprise URLs",
"channels.field_user_key": "User key",
"channels.field_webhook_url": "Webhook URL",
"channels.help_apprise": "Reaches over 100 services through an Apprise API server: give Apprise URLs or the key of a configuration stored there.",
"channels.help_opsgenie": "The alert closes when the incident is resolved.",
"channels.help_pagerduty": "Use the integration key of an Events API v2 integration; resolving closes the PagerDuty incident.",
"channels.help_signal": "Needs a signal-cli REST API server (bbernhard/signal-cli-rest-api) with a registered number.",
"channels.help_teams": "Use the URL of a Teams workflow \"Post to a channel when a webhook request is received\".",
"channels.help_telegram": "Create a bot with @BotFather; the chat ID of a group starts with -100.",
"channels.intro": "Every enabled channel is notified when a monitor goes down in all of its regions and when it recovers.", "channels.intro": "Every enabled channel is notified when a monitor goes down in all of its regions and when it recovers.",
"channels.language": "Language", "channels.language": "Language",
"channels.new_email": "New email channel", "channels.new_email": "New email channel",
"channels.new_service": "Other services",
"channels.new_webhook": "New webhook", "channels.new_webhook": "New webhook",
"channels.optional": "optional",
"channels.secret_now": "Signing secret: verify the X-Uptimesebi-Signature header with it. It will not be shown again.", "channels.secret_now": "Signing secret: verify the X-Uptimesebi-Signature header with it. It will not be shown again.",
"channels.service": "Service",
"channels.service_intro": "Chat, push and paging services. Tokens and keys are stored encrypted and never shown again.",
"channels.test": "Send test", "channels.test": "Send test",
"channels.test_ok": "Test notification delivered.", "channels.test_ok": "Test notification delivered.",
"channels.title": "Notifications", "channels.title": "Notifications",
"channels.to": "Recipients", "channels.to": "Recipients",
"channels.type_apprise": "Apprise",
"channels.type_discord": "Discord",
"channels.type_email": "Email", "channels.type_email": "Email",
"channels.type_googlechat": "Google Chat",
"channels.type_gotify": "Gotify",
"channels.type_matrix": "Matrix",
"channels.type_mattermost": "Mattermost",
"channels.type_ntfy": "ntfy",
"channels.type_opsgenie": "Opsgenie",
"channels.type_pagerduty": "PagerDuty",
"channels.type_pushbullet": "Pushbullet",
"channels.type_pushover": "Pushover",
"channels.type_rocketchat": "Rocket.Chat",
"channels.type_signal": "Signal",
"channels.type_slack": "Slack",
"channels.type_teams": "Microsoft Teams",
"channels.type_telegram": "Telegram",
"channels.type_webhook": "Webhook", "channels.type_webhook": "Webhook",
"channels.url": "Webhook URL", "channels.url": "Webhook URL",
"checkers.avg_latency": "Average latency", "checkers.avg_latency": "Average latency",
@@ -189,6 +238,7 @@
"error.invalid_assertion_path": "A condition path is invalid. Use keys separated by dots and [n] for array elements.", "error.invalid_assertion_path": "A condition path is invalid. Use keys separated by dots and [n] for array elements.",
"error.invalid_assertion_value": "Comparisons with <, >, ≤ and ≥ need a number.", "error.invalid_assertion_value": "Comparisons with <, >, ≤ and ≥ need a number.",
"error.invalid_assertions": "Add between 1 and 10 conditions.", "error.invalid_assertions": "Add between 1 and 10 conditions.",
"error.invalid_channel_settings": "Fill in the required fields; addresses must be https URLs.",
"error.invalid_code": "Invalid code.", "error.invalid_code": "Invalid code.",
"error.invalid_config": "The check settings are not valid.", "error.invalid_config": "The check settings are not valid.",
"error.invalid_credentials": "Wrong email or password.", "error.invalid_credentials": "Wrong email or password.",
@@ -595,6 +645,11 @@
"monitors.type_tls": "TLS certificate", "monitors.type_tls": "TLS certificate",
"monitors.uptime_chart": "Uptime per period", "monitors.uptime_chart": "Uptime per period",
"monitors.verify_tls": "Verify TLS certificate", "monitors.verify_tls": "Verify TLS certificate",
"notify.duration": "Down for {{.Duration}}",
"notify.test_body": "If you can read this, the channel works.",
"notify.title_opened": "{{.Monitor}} is down",
"notify.title_resolved": "{{.Monitor}} is up again",
"notify.title_test": "Test from UptimeSebi",
"org.policy": "Sign-in policy", "org.policy": "Sign-in policy",
"org.require_sso": "Require SSO", "org.require_sso": "Require SSO",
"org.require_sso_hint": "Members must sign in through this organization's identity provider. The owner can still use a password so a broken IdP cannot lock you out.", "org.require_sso_hint": "Members must sign in through this organization's identity provider. The owner can still use a password so a broken IdP cannot lock you out.",
@@ -0,0 +1,10 @@
-- +goose Up
-- Channel types follow notify.Providers; the application validates them
-- and their settings, secrets of which are sealed in config.
ALTER TABLE notification_channels DROP CONSTRAINT notification_channels_type_check;
ALTER TABLE notification_channels ADD CONSTRAINT notification_channels_type_check CHECK (type ~ '^[a-z]{2,32}$');
-- +goose Down
DELETE FROM notification_channels WHERE type NOT IN ('webhook', 'email');
ALTER TABLE notification_channels DROP CONSTRAINT notification_channels_type_check;
ALTER TABLE notification_channels ADD CONSTRAINT notification_channels_type_check CHECK (type IN ('webhook', 'email'));
+88
View File
@@ -766,6 +766,7 @@ type ChannelsView struct {
EmailAvailable bool EmailAvailable bool
CanWrite bool CanWrite bool
Languages []string Languages []string
Providers []ProviderOption
} }
templ ChannelsPage(p Page, me Me, v ChannelsView) { templ ChannelsPage(p Page, me Me, v ChannelsView) {
@@ -834,11 +835,98 @@ templ ChannelsPage(p Page, me Me, v ChannelsView) {
<p class="text-sm text-muted">{ i18n.T(ctx, "error.email_not_configured") }</p> <p class="text-sm text-muted">{ i18n.T(ctx, "error.email_not_configured") }</p>
} }
</section> </section>
<section class="md:col-span-2">
@sectionHeading("channels.new_service")
<p class="mb-4 max-w-2xl text-sm text-muted">{ i18n.T(ctx, "channels.service_intro") }</p>
<form data-api="/org/channels" data-next="/settings/channels" class="grid gap-x-8 md:grid-cols-2">
<div>
@formError()
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "channels.service") }</span>
<select name="type" data-type-select class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
for _, pr := range v.Providers {
<option value={ pr.Type }>{ i18n.T(ctx, "channels.type_"+pr.Type) }</option>
}
</select>
</label>
@valueField(i18n.T(ctx, "sso.field.name"), "name", "", "Ops", true)
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "channels.language") }</span>
<select name="locale" class="w-40 border border-rule bg-transparent px-2 py-1.5 text-sm">
for _, l := range v.Languages {
<option value={ l } selected?={ l == i18n.Lang(ctx) }>{ i18n.T(ctx, "lang."+l) }</option>
}
</select>
</label>
</div>
<div>
for i, pr := range v.Providers {
<fieldset data-type={ pr.Type } disabled?={ i != 0 } hidden?={ i != 0 }>
if pr.Help != "" {
<p class="mb-3 text-xs text-muted">{ pr.Help }</p>
}
for _, f := range pr.Fields {
@providerField(f)
}
</fieldset>
}
@submit(i18n.T(ctx, "channels.create"))
</div>
</form>
</section>
</div> </div>
} }
} }
} }
// ProviderOption is a notification service the form offers.
type ProviderOption struct {
Type string
Help string
Fields []ProviderField
}
// ProviderField is a setting of a service.
type ProviderField struct {
Name string
Label string
Required bool
Secret bool
Kind string
Options []string
Default string
}
templ providerField(f ProviderField) {
<label class="mb-4 block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">
{ f.Label }
if !f.Required {
<span class="normal-case tracking-normal">{ " · " + i18n.T(ctx, "channels.optional") }</span>
}
</span>
switch {
case f.Kind == "select":
<select name={ "settings." + f.Name } class="w-full border border-rule bg-transparent px-2 py-1.5 font-mono text-sm">
for _, o := range f.Options {
<option value={ o } selected?={ o == f.Default }>{ o }</option>
}
</select>
case f.Secret:
<input type="password" name={ "settings." + f.Name } required?={ f.Required } autocomplete="off" class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"/>
default:
<input
type={ map[bool]string{true: "number", false: "text"}[f.Kind == "number"] }
name={ "settings." + f.Name }
value={ f.Default }
required?={ f.Required }
placeholder={ map[bool]string{true: "https://", false: ""}[f.Kind == "url"] }
class="w-full border border-rule bg-transparent px-2.5 py-1.5 font-mono text-sm outline-none focus:border-ink"
/>
}
</label>
}
templ groupSelect(name string, groups []GroupOption, selected string, allowNone bool) { templ groupSelect(name string, groups []GroupOption, selected string, allowNone bool) {
<select name={ name } data-nullable class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm"> <select name={ name } data-nullable class="w-full border border-rule bg-transparent px-2 py-1.5 text-sm">
if allowNone { if allowNone {
File diff suppressed because it is too large. Load diff