All checks were successful
release-tag / release-image (push) Successful in 2m3s
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package notify
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"releasewatcher/internal/store"
|
|
)
|
|
|
|
type ReleaseNotifier interface {
|
|
NotifyReleaseCreated(ctx context.Context, release store.Release, software store.Software) error
|
|
}
|
|
|
|
// SoftwareChannelProvisioner ist optional. Implementierungen können beim Anlegen
|
|
// einer Software automatisch einen Zielkanal bereitstellen, z. B. in Discord.
|
|
type SoftwareChannelProvisioner interface {
|
|
EnsureSoftwareChannel(ctx context.Context, software store.Software, manufacturer store.Manufacturer) (channelID string, err error)
|
|
}
|
|
|
|
type NoopNotifier struct{}
|
|
|
|
func (NoopNotifier) NotifyReleaseCreated(ctx context.Context, release store.Release, software store.Software) error {
|
|
return nil
|
|
}
|
|
|
|
type LoggingNotifier struct{ Log *slog.Logger }
|
|
|
|
func (n LoggingNotifier) NotifyReleaseCreated(ctx context.Context, release store.Release, software store.Software) error {
|
|
if n.Log != nil {
|
|
n.Log.InfoContext(ctx, "release notification", "software", software.Name, "version", release.Version, "channel", release.Channel)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DiscordWebhookNotifier ist absichtlich nur als Adapter-Schnittstelle vorbereitet.
|
|
// Implementiere hier später deinen Bot/Webhook-Aufruf und binde ihn in cmd/releasewatcher/main.go ein.
|
|
type DiscordWebhookNotifier struct{}
|
|
|
|
func (DiscordWebhookNotifier) NotifyReleaseCreated(ctx context.Context, release store.Release, software store.Software) error {
|
|
return nil
|
|
}
|