prevent sending email when no recipients

This commit is contained in:
Arjun Patel
2026-06-09 07:58:57 -07:00
parent 60b1c3e24f
commit 3a7b896f3a
+13 -11
View File
@@ -284,18 +284,20 @@ func (s *serviceImpl) AcceptInvitation(ctx context.Context, networkID, email, hu
} }
} }
newMemberEmailPrefix := strings.Split(normalized, "@")[0] if len(emailRecipients) > 0 {
_, err = s.aeroSvc.ShootEmail(ctx, &pbaero.ShootEmailRequest{ newMemberEmailPrefix := strings.Split(normalized, "@")[0]
ToEmails: emailRecipients, _, err = s.aeroSvc.ShootEmail(ctx, &pbaero.ShootEmailRequest{
Subject: fmt.Sprintf("A new member has joined %s", network.Name), ToEmails: emailRecipients,
TemplateData: &pbaero.ShootEmailRequest_SimpleHtmlData{ Subject: fmt.Sprintf("A new member has joined %s", network.Name),
SimpleHtmlData: &pbaero.SimpleHtmlData{ TemplateData: &pbaero.ShootEmailRequest_SimpleHtmlData{
Html: buildNewMemberHTML(network.Name, newMemberEmailPrefix), SimpleHtmlData: &pbaero.SimpleHtmlData{
Html: buildNewMemberHTML(network.Name, newMemberEmailPrefix),
},
}, },
}, })
}) if err != nil {
if err != nil { flog.Warn("unable to send email notification", "email", email, "network", network.Name)
flog.Warn("unable to send email notification", "email", email, "network", network.Name) }
} }
} }