This commit is contained in:
41
internal/notify/notify.go
Normal file
41
internal/notify/notify.go
Normal file
@@ -0,0 +1,41 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user