From a5985b362a8a57fe07bda3681126dba1dd39f244 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 2 Feb 2026 23:04:33 +0000 Subject: [PATCH] Generate public_id after all other dataa Because we use it to generate the ID. --- comms/email/initial.go | 5 +++-- comms/email/report_notification_confirmation.go | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/comms/email/initial.go b/comms/email/initial.go index 45438088..aaacdc44 100644 --- a/comms/email/initial.go +++ b/comms/email/initial.go @@ -45,15 +45,16 @@ func urlUnsubscribe(email string) string { func sendEmailInitialContact(ctx context.Context, destination string) error { //data := pgtypes.HStore{} data := make(map[string]string, 0) - public_id := generatePublicId(enums.CommsMessagetypeemailInitialContact, data) source := config.ForwardEmailReportAddress data["Destination"] = destination data["Source"] = source - data["URLBrowser"] = urlEmailInBrowser(public_id) data["URLLogo"] = config.MakeURLReport("/static/img/nidus-logo-no-lettering-64.png") data["URLSubscribe"] = config.MakeURLReport("/email/confirm?email=%s", destination) data["URLUnsubscribe"] = urlUnsubscribe(destination) + public_id := generatePublicId(enums.CommsMessagetypeemailInitialContact, data) + data["URLBrowser"] = urlEmailInBrowser(public_id) + text, html, err := renderEmailTemplates(templateInitialID, data) if err != nil { return fmt.Errorf("Failed to render email temlates: %w", err) diff --git a/comms/email/report_notification_confirmation.go b/comms/email/report_notification_confirmation.go index cf4b7e6f..1551d6cd 100644 --- a/comms/email/report_notification_confirmation.go +++ b/comms/email/report_notification_confirmation.go @@ -48,7 +48,6 @@ func sendEmailReportConfirmation(ctx context.Context, job Job) error { return fmt.Errorf("Failed to handle initial email: %w", err) } data := make(map[string]string, 0) - public_id := generatePublicId(enums.CommsMessagetypeemailInitialContact, data) data["report_id"] = j.reportID report_id_str := publicReportID(j.reportID) data["ReportIDStr"] = report_id_str @@ -56,7 +55,10 @@ func sendEmailReportConfirmation(ctx context.Context, job Job) error { data["URLReportStatus"] = config.MakeURLReport("/status/%s", j.reportID) data["URLReportUnsubscribe"] = config.MakeURLReport("/email/unsubscribe/report/%s", j.reportID) data["URLUnsubscribe"] = urlUnsubscribe(j.destination()) + + public_id := generatePublicId(enums.CommsMessagetypeemailReportNotificationConfirmation, data) data["URLViewInBrowser"] = urlEmailInBrowser(public_id) + text, html, err := renderEmailTemplates(templateReportNotificationConfirmationID, data) if err != nil { return fmt.Errorf("Failed to render email report notification template: %w", err)