From 488640c80c559221a685e309318b852b2698a506 Mon Sep 17 00:00:00 2001 From: Alano Terblanche Date: Fri, 3 Dec 2021 13:03:27 +0100 Subject: [PATCH] fix: courier --- cmd/courier/watch.go | 8 +++++--- courier/courier.go | 5 ++++- driver/registry_default.go | 9 +++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/courier/watch.go b/cmd/courier/watch.go index d9818205d31b..45c515a28068 100644 --- a/cmd/courier/watch.go +++ b/cmd/courier/watch.go @@ -2,14 +2,16 @@ package courier import ( cx "context" + "net/http" + + "github.com/spf13/cobra" + "github.com/urfave/negroni" + "github.com/ory/graceful" "github.com/ory/kratos/driver" "github.com/ory/kratos/x" "github.com/ory/x/configx" "github.com/ory/x/reqlog" - "github.com/spf13/cobra" - "github.com/urfave/negroni" - "net/http" ) func NewWatchCmd() *cobra.Command { diff --git a/courier/courier.go b/courier/courier.go index 6092ba90cc05..3e800408e560 100644 --- a/courier/courier.go +++ b/courier/courier.go @@ -31,7 +31,7 @@ type ( SMTPDependencies interface { PersistenceProvider x.LoggingProvider - CourierConfig(ctx context.Context) SMTPConfig + ConfigProvider } TemplateTyper func(t EmailTemplate) (TemplateType, error) EmailTemplateFromMessage func(c SMTPConfig, msg Message) (EmailTemplate, error) @@ -44,6 +44,9 @@ type ( Provider interface { Courier(ctx context.Context) *Courier } + ConfigProvider interface { + CourierConfig(ctx context.Context) SMTPConfig + } ) func NewSMTP(ctx context.Context, d SMTPDependencies) *Courier { diff --git a/driver/registry_default.go b/driver/registry_default.go index 8952f1df1f96..56b00a024964 100644 --- a/driver/registry_default.go +++ b/driver/registry_default.go @@ -7,6 +7,8 @@ import ( "sync" "time" + "github.com/gobuffalo/pop/v5" + "github.com/ory/nosurf" "github.com/ory/kratos/selfservice/strategy/webauthn" @@ -22,8 +24,6 @@ import ( prometheus "github.com/ory/x/prometheusx" - "github.com/gobuffalo/pop/v5" - "github.com/ory/kratos/cipher" "github.com/ory/kratos/continuity" "github.com/ory/kratos/hash" @@ -260,10 +260,7 @@ func (m *RegistryDefault) Config(ctx context.Context) *config.Config { } func (m *RegistryDefault) CourierConfig(ctx context.Context) courier.SMTPConfig { - if m.c == nil { - panic("configuration not set") - } - return corp.ContextualizeConfig(ctx, m.c) + return m.Config(ctx) } func (m *RegistryDefault) SMTPConfig(ctx context.Context) courier.SMTPConfig {