From 17f61b0479def7700d6b0189edda5e575d498bbf Mon Sep 17 00:00:00 2001 From: Shannon Donahue <> Date: Tue, 7 Oct 2025 16:44:24 -0400 Subject: [PATCH] [Email Bug] Fix the emails replacing username functionality. Was utilizing slicing methodology that may be leading to errors in recipients. --- internal/service/mailer/helpers.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/service/mailer/helpers.go b/internal/service/mailer/helpers.go index 69b91d40..d72cad5d 100644 --- a/internal/service/mailer/helpers.go +++ b/internal/service/mailer/helpers.go @@ -102,21 +102,18 @@ func LookupEmailsForUsernames(ctx context.Context, email *models.Email) error { // ...and finally, replace the usernames -> in the lists on the email objects for i, name := range email.Recipients { - if _, ok := toLookup[name]; ok { - email.Recipients = append(email.Recipients[:i], toLookup[name]) - email.Recipients = append(email.Recipients, email.Recipients[i+1:]...) + if emailAddr, ok := toLookup[name]; ok { + email.Recipients[i] = emailAddr } } for i, name := range email.CcList { - if _, ok := toLookup[name]; ok { - email.CcList = append(email.CcList[:i], toLookup[name]) - email.CcList = append(email.CcList, email.CcList[i+1:]...) + if emailAddr, ok := toLookup[name]; ok { + email.CcList[i] = emailAddr } } for i, name := range email.BccList { - if _, ok := toLookup[name]; ok { - email.BccList = append(email.BccList[:i], toLookup[name]) - email.BccList = append(email.BccList, email.BccList[i+1:]...) + if emailAddr, ok := toLookup[name]; ok { + email.BccList[i] = emailAddr } }