Generate public_id after all other dataa
Because we use it to generate the ID.
This commit is contained in:
parent
a67279db88
commit
a5985b362a
2 changed files with 6 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue