From 07a8fdbbd54588f1b5c21f96d3a4c518e3bb6509 Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Mon, 18 Jul 2022 16:27:53 +0530 Subject: [PATCH] Fix test notification cli command Also, addresses issue with SMTP_* env vars value, which were ignored on server startup. --- app/boot_levels.go | 2 -- auth/commands/commands.go | 9 ++++++++- pkg/mail/mail.go | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/boot_levels.go b/app/boot_levels.go index 864830dc3..19fdd4ac3 100644 --- a/app/boot_levels.go +++ b/app/boot_levels.go @@ -731,8 +731,6 @@ func applySmtpOptionsToSettings(ctx context.Context, log *zap.Logger, opt option "To avoid confusion and potential issues, we suggest you to " + "remove all SMTP_* variables") } - - return } // SMTP server settings do not exist but diff --git a/auth/commands/commands.go b/auth/commands/commands.go index 9e8a493b1..f3642b5ce 100644 --- a/auth/commands/commands.go +++ b/auth/commands/commands.go @@ -18,6 +18,7 @@ import ( type ( serviceInitializer interface { InitServices(ctx context.Context) error + Activate(ctx context.Context) error Options() *options.Options } ) @@ -28,6 +29,12 @@ func commandPreRunInitService(app serviceInitializer) func(*cobra.Command, []str } } +func commandPreRunInitActivate(app serviceInitializer) func(*cobra.Command, []string) error { + return func(_ *cobra.Command, _ []string) error { + return app.Activate(cli.Context()) + } +} + func Command(ctx context.Context, app serviceInitializer, storeInit func(ctx context.Context) (store.Storer, error)) *cobra.Command { var ( enableDiscoveredProvider bool @@ -151,7 +158,7 @@ func Command(ctx context.Context, app serviceInitializer, storeInit func(ctx con Use: "test-notifications [recipient]", Short: "Sends samples of all authentication notification to recipient", Args: cobra.ExactArgs(1), - PreRunE: commandPreRunInitService(app), + PreRunE: commandPreRunInitActivate(app), Run: func(cmd *cobra.Command, args []string) { var ( err error diff --git a/pkg/mail/mail.go b/pkg/mail/mail.go index 0ed4c2e6d..7a5ed8742 100644 --- a/pkg/mail/mail.go +++ b/pkg/mail/mail.go @@ -81,7 +81,7 @@ func New() *gomail.Message { return message } -// Sends message with SMTP dialer +// Send message with SMTP dialer func Send(message *gomail.Message, dd ...Dialer) (err error) { for _, d := range append(dd, defaultDialer) { if d == nil {