Skip to content

Commit

Permalink
enhancement: add tags to SES, same as mailgun
Browse files Browse the repository at this point in the history
  • Loading branch information
goenning committed Apr 29, 2022
1 parent 7851f9d commit 263e270
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/services/email/awsses/awsses.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
ses "github.com/aws/aws-sdk-go/service/sesv2"
"github.com/getfider/fider/app"
"github.com/getfider/fider/app/models/cmd"
"github.com/getfider/fider/app/models/dto"
"github.com/getfider/fider/app/models/entity"
"github.com/getfider/fider/app/models/query"
"github.com/getfider/fider/app/pkg/bus"
"github.com/getfider/fider/app/pkg/env"
Expand Down Expand Up @@ -82,6 +84,14 @@ func sendMail(ctx context.Context, c *cmd.SendMail) {
})

message := email.RenderMessage(ctx, c.TemplateName, c.From.Address, c.Props.Merge(to.Props))
tags := []*ses.MessageTag{
{Name: aws.String("template"), Value: aws.String(c.TemplateName)},
}

tenant, ok := ctx.Value(app.TenantCtxKey).(*entity.Tenant)
if ok && !env.IsSingleHostMode() {
tags = append(tags, &ses.MessageTag{Name: aws.String("tenant"), Value: aws.String(tenant.Subdomain)})
}

input := &ses.SendEmailInput{
FromEmailAddress: aws.String(c.From.String()),
Expand All @@ -104,6 +114,7 @@ func sendMail(ctx context.Context, c *cmd.SendMail) {
},
},
},
EmailTags: tags,
}

result, err := sesClient.SendEmailWithContext(ctx, input)
Expand Down

0 comments on commit 263e270

Please sign in to comment.