From cb3c4e8d2c3d15ab1fac61e63b37d60b08adf052 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 2 Feb 2026 23:58:51 +0000 Subject: [PATCH] Save the template ID and email type in email_log --- comms/email/db.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/comms/email/db.go b/comms/email/db.go index 86579266..bf211ee9 100644 --- a/comms/email/db.go +++ b/comms/email/db.go @@ -69,6 +69,15 @@ func ensureInDB(ctx context.Context, destination string) (err error) { func insertEmailLog(ctx context.Context, data map[string]string, destination string, public_id string, source string, subject string, template_id int32) (err error) { data_for_insert := convertToPGData(data) + var type_ enums.CommsMessagetypeemail + switch template_id { + case templateReportNotificationConfirmationID: + type_ = enums.CommsMessagetypeemailReportNotificationConfirmation + case templateInitialID: + type_ = enums.CommsMessagetypeemailInitialContact + default: + return fmt.Errorf("Unrecognized template ID %d", template_id) + } _, err = models.CommsEmailLogs.Insert(&models.CommsEmailLogSetter{ //ID: Created: omit.From(time.Now()), @@ -78,9 +87,9 @@ func insertEmailLog(ctx context.Context, data map[string]string, destination str SentAt: omitnull.FromPtr[time.Time](nil), Source: omit.From(source), Subject: omit.From(subject), - TemplateID: omit.From(templateInitialID), + TemplateID: omit.From(template_id), TemplateData: omit.From(data_for_insert), - Type: omit.From(enums.CommsMessagetypeemailInitialContact), + Type: omit.From(type_), }).One(ctx, db.PGInstance.BobDB) return err