All checks were successful
CI / changes (push) Successful in 19s
CI / test (push) Successful in 31s
CI / build-ai-gateway (push) Successful in 1m8s
CI / build-ha-gateway (push) Successful in 1m19s
CI / build-discord-bot (push) Successful in 59s
CI / build-alexa-bridge (push) Successful in 1m8s
CI / build-alert-bridge (push) Successful in 1m17s
CI / build-tts-gateway (push) Successful in 1m10s
CI / build-tts-sidecar (push) Has been skipped
CI / build-tts-model (push) Has been skipped
New standalone service that receives authenticated HTTP POSTs (e.g. from a cronjob elsewhere on the home network) and posts them to a Discord channel via an Incoming Webhook. Fire-and-forget, no dependency on discord-bot's bot session at all - mirrors alexa-bridge's precedent of a small bridge service with its own HTTP listener and auth rather than adding an inbound edge to an existing internal service. Wires alert-bridge into go.work, CI (changes filter, test job, new build-alert-bridge job), and the other five Dockerfiles' COPY lines. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
28 lines
734 B
Go
28 lines
734 B
Go
package app
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitea.nik4nao.com/nik/home-services/alert-bridge/internal/core/domain"
|
|
"gitea.nik4nao.com/nik/home-services/alert-bridge/internal/core/ports/driven"
|
|
)
|
|
|
|
// AlertApp orchestrates delivering an incoming alert to its Notifier.
|
|
type AlertApp struct {
|
|
notifier driven.Notifier
|
|
}
|
|
|
|
// NewAlertApp constructs the alert application service.
|
|
func NewAlertApp(notifier driven.Notifier) *AlertApp {
|
|
return &AlertApp{notifier: notifier}
|
|
}
|
|
|
|
// Handle delivers one alert, wrapping any delivery failure for the caller.
|
|
func (a *AlertApp) Handle(ctx context.Context, alert domain.Alert) error {
|
|
if err := a.notifier.Notify(ctx, alert); err != nil {
|
|
return fmt.Errorf("notify: %w", err)
|
|
}
|
|
return nil
|
|
}
|