Skip to content

Commit 0c8f6c0

Browse files
authored
fix: web base url bound to env (#300)
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
1 parent a99c661 commit 0c8f6c0

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func configEnvKeys() {
4444
failIfError(viper.BindEnv("jwt_private_key"))
4545
failIfError(viper.BindEnv("jwt_public_key"))
4646
failIfError(viper.BindEnv("api_allowed_origins"))
47+
failIfError(viper.BindEnv("web_base_url"))
4748
failIfError(viper.BindEnv("sso_config"))
4849
failIfError(viper.BindEnv("email_config"))
4950
failIfError(viper.BindEnv("metrics_enabled"))

internal/service/email/providers/ses.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,26 @@ func (p *sesProvider) Send(ctx context.Context, message *emailtypes.Message) (*e
8181
return nil, fmt.Errorf("no from address specified")
8282
}
8383

84+
// Set default from name if not provided
85+
fromName := message.FromName
86+
if fromName == "" {
87+
fromName = p.config.FromName
88+
}
89+
90+
// Format From address if name is provided
91+
fromAddress := from
92+
if fromName != "" {
93+
fromAddress = fmt.Sprintf("%s <%s>", fromName, from)
94+
}
95+
8496
// Validate recipients
8597
if len(message.To) == 0 {
8698
return nil, fmt.Errorf("no recipients specified")
8799
}
88100

89101
// Build SES input
90102
input := &sesv2.SendEmailInput{
91-
FromEmailAddress: aws.String(from),
103+
FromEmailAddress: aws.String(fromAddress),
92104
Destination: &types.Destination{
93105
ToAddresses: message.To,
94106
},
@@ -108,7 +120,7 @@ func (p *sesProvider) Send(ctx context.Context, message *emailtypes.Message) (*e
108120
// Send email
109121
result, err := p.client.SendEmail(ctx, input)
110122
if err != nil {
111-
p.logger.Errorw("Failed to send email via SES", "error", err, "to", message.To)
123+
p.logger.Errorw("Failed to send email via SES", "error", err, "from", fromAddress, "to", message.To)
112124
return &emailtypes.SendResult{
113125
Success: false,
114126
Error: err.Error(),

0 commit comments

Comments
 (0)