diff --git a/pkg/notifier/notifier.go b/pkg/notifier/notifier.go index d195e856..f2ae8801 100644 --- a/pkg/notifier/notifier.go +++ b/pkg/notifier/notifier.go @@ -242,14 +242,14 @@ func (a App) sendNotification(ctx context.Context, ketchupToNotify map[model.Use "releases": releases, } - mailRequest := mailerModel.NewMailRequest().Template("ketchup").From("ketchup@vibioh.fr").As("Ketchup").To(user.Email).Data(payload) + mr := mailerModel.NewMailRequest().Template("ketchup").From("ketchup@vibioh.fr").As("Ketchup").To(user.Email).Data(payload) subject := fmt.Sprintf("Ketchup - %d new release", len(releases)) if len(releases) > 1 { subject += "s" } - mailRequest.WithSubject(subject) + mr = mr.WithSubject(subject) - if err := a.mailerApp.Send(ctx, *mailRequest); err != nil { + if err := a.mailerApp.Send(ctx, mr); err != nil { return fmt.Errorf("unable to send email to %s: %s", user.Email, err) } } diff --git a/pkg/provider/github/github.go b/pkg/provider/github/github.go index 83b21c29..69206f92 100644 --- a/pkg/provider/github/github.go +++ b/pkg/provider/github/github.go @@ -12,7 +12,6 @@ import ( "github.com/ViBiOh/httputils/v4/pkg/flags" "github.com/ViBiOh/httputils/v4/pkg/httpjson" "github.com/ViBiOh/httputils/v4/pkg/logger" - "github.com/ViBiOh/httputils/v4/pkg/redis" "github.com/ViBiOh/httputils/v4/pkg/request" "github.com/ViBiOh/ketchup/pkg/model" "github.com/ViBiOh/ketchup/pkg/semver" @@ -31,6 +30,11 @@ var ( } ) +type redis interface { + Ping() error + Exclusive(context.Context, string, time.Duration, func(context.Context) error) error +} + // Tag describes a GitHub Tag type Tag struct { Name string `json:"name"` @@ -58,7 +62,7 @@ type Config struct { } type app struct { - redisApp redis.App + redisApp redis token string } @@ -70,14 +74,14 @@ func Flags(fs *flag.FlagSet, prefix string) Config { } // New creates new App from Config -func New(config Config, redisApp redis.App) App { +func New(config Config, redisApp redis) App { return app{ token: strings.TrimSpace(*config.token), redisApp: redisApp, } } -func (a app) newClient() *request.Request { +func (a app) newClient() request.Request { return request.New().Header("Authorization", fmt.Sprintf("token %s", a.token)).WithClient(httpClient) }