From 263e2709fd145f3ea511e5557e170102899995b0 Mon Sep 17 00:00:00 2001 From: goenning Date: Fri, 29 Apr 2022 07:53:20 +0100 Subject: [PATCH] enhancement: add tags to SES, same as mailgun --- app/services/email/awsses/awsses.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/services/email/awsses/awsses.go b/app/services/email/awsses/awsses.go index b7e20f4b7..b4ece6e5e 100644 --- a/app/services/email/awsses/awsses.go +++ b/app/services/email/awsses/awsses.go @@ -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" @@ -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()), @@ -104,6 +114,7 @@ func sendMail(ctx context.Context, c *cmd.SendMail) { }, }, }, + EmailTags: tags, } result, err := sesClient.SendEmailWithContext(ctx, input)