Fix various breakages in email links
This commit is contained in:
parent
73ed495b72
commit
a67279db88
8 changed files with 59 additions and 20 deletions
|
|
@ -51,7 +51,7 @@ func sendEmailInitialContact(ctx context.Context, destination string) error {
|
||||||
data["Source"] = source
|
data["Source"] = source
|
||||||
data["URLBrowser"] = urlEmailInBrowser(public_id)
|
data["URLBrowser"] = urlEmailInBrowser(public_id)
|
||||||
data["URLLogo"] = config.MakeURLReport("/static/img/nidus-logo-no-lettering-64.png")
|
data["URLLogo"] = config.MakeURLReport("/static/img/nidus-logo-no-lettering-64.png")
|
||||||
data["URLSubscribe"] = config.MakeURLReport("/email/subscribe?email=%s", destination)
|
data["URLSubscribe"] = config.MakeURLReport("/email/confirm?email=%s", destination)
|
||||||
data["URLUnsubscribe"] = urlUnsubscribe(destination)
|
data["URLUnsubscribe"] = urlUnsubscribe(destination)
|
||||||
|
|
||||||
text, html, err := renderEmailTemplates(templateInitialID, data)
|
text, html, err := renderEmailTemplates(templateInitialID, data)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func sendEmailReportConfirmation(ctx context.Context, job Job) error {
|
||||||
report_id_str := publicReportID(j.reportID)
|
report_id_str := publicReportID(j.reportID)
|
||||||
data["ReportIDStr"] = report_id_str
|
data["ReportIDStr"] = report_id_str
|
||||||
data["URLLogo"] = config.MakeURLReport("/static/img/nidus-logo-no-lettering-64.png")
|
data["URLLogo"] = config.MakeURLReport("/static/img/nidus-logo-no-lettering-64.png")
|
||||||
data["URLReportStatus"] = config.MakeURLReport("/foo")
|
data["URLReportStatus"] = config.MakeURLReport("/status/%s", j.reportID)
|
||||||
data["URLReportUnsubscribe"] = config.MakeURLReport("/email/unsubscribe/report/%s", j.reportID)
|
data["URLReportUnsubscribe"] = config.MakeURLReport("/email/unsubscribe/report/%s", j.reportID)
|
||||||
data["URLUnsubscribe"] = urlUnsubscribe(j.destination())
|
data["URLUnsubscribe"] = urlUnsubscribe(j.destination())
|
||||||
data["URLViewInBrowser"] = urlEmailInBrowser(public_id)
|
data["URLViewInBrowser"] = urlEmailInBrowser(public_id)
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ var (
|
||||||
templateReportNotificationConfirmationID int32
|
templateReportNotificationConfirmationID int32
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ContentEmailRender struct {
|
||||||
|
IsBrowser bool
|
||||||
|
C any
|
||||||
|
}
|
||||||
|
|
||||||
type templatePair struct {
|
type templatePair struct {
|
||||||
baseName string
|
baseName string
|
||||||
messageType enums.CommsMessagetypeemail
|
messageType enums.CommsMessagetypeemail
|
||||||
|
|
@ -98,7 +103,11 @@ func RenderHTML(template_id int32, s pgtypes.HStore) (html []byte, err error) {
|
||||||
return []byte{}, fmt.Errorf("Failed to lookup template %d", template_id)
|
return []byte{}, fmt.Errorf("Failed to lookup template %d", template_id)
|
||||||
}
|
}
|
||||||
buf_html := &bytes.Buffer{}
|
buf_html := &bytes.Buffer{}
|
||||||
err = t.executeTemplateHTML(buf_html, data)
|
content := ContentEmailRender{
|
||||||
|
C: data,
|
||||||
|
IsBrowser: true,
|
||||||
|
}
|
||||||
|
err = t.executeTemplateHTML(buf_html, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, fmt.Errorf("Failed to render HTML template: %w", err)
|
return []byte{}, fmt.Errorf("Failed to render HTML template: %w", err)
|
||||||
}
|
}
|
||||||
|
|
@ -320,12 +329,16 @@ func publicReportID(s string) string {
|
||||||
return s[0:4] + "-" + s[4:8] + "-" + s[8:12]
|
return s[0:4] + "-" + s[4:8] + "-" + s[8:12]
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderEmailTemplates(template_id int32, content map[string]string) (text string, html string, err error) {
|
func renderEmailTemplates(template_id int32, data map[string]string) (text string, html string, err error) {
|
||||||
buf_txt := &bytes.Buffer{}
|
buf_txt := &bytes.Buffer{}
|
||||||
t, ok := templateByID[template_id]
|
t, ok := templateByID[template_id]
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", "", fmt.Errorf("Failed to lookup template %d", template_id)
|
return "", "", fmt.Errorf("Failed to lookup template %d", template_id)
|
||||||
}
|
}
|
||||||
|
content := ContentEmailRender{
|
||||||
|
C: data,
|
||||||
|
IsBrowser: false,
|
||||||
|
}
|
||||||
err = t.executeTemplateTXT(buf_txt, content)
|
err = t.executeTemplateTXT(buf_txt, content)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("Failed to render TXT template: %w", err)
|
return "", "", fmt.Errorf("Failed to render TXT template: %w", err)
|
||||||
|
|
|
||||||
|
|
@ -64,34 +64,34 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{if .IsBrowser}}
|
{{if not .IsBrowser}}
|
||||||
<div class="view-browser">
|
<div class="view-browser">
|
||||||
Email not displaying correctly? <a href="{{.url_browser}}">View it in your browser</a>
|
Email not displaying correctly? <a href="{{.C.URLBrowser}}">View it in your browser</a>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<!-- Logo Placeholder -->
|
<!-- Logo Placeholder -->
|
||||||
<img src="{{.URLLogo}}" alt="Report Mosquitoes Online Logo" class="logo"></img>
|
<img src="{{.C.URLLogo}}" alt="Report Mosquitoes Online Logo" class="logo"></img>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>Welcome</h1>
|
<h1>Welcome</h1>
|
||||||
|
|
||||||
<p>We're sending you this email because it's the first time we've gotten this email address ({{.Destination}}).</p>
|
<p>We're sending you this email because it's the first time we've gotten this email address ({{.C.Destination}}).</p>
|
||||||
|
|
||||||
<p>If you'd rather not receive emails from us you can reply with "Unsubscribe" in the subject or body of the email. You can also use the "Unsubscribe" feature of your mail client, if it supports list unsubscribes.</p>
|
<p>If you'd rather not receive emails from us you can reply with "Unsubscribe" in the subject or body of the email. You can also use the "Unsubscribe" feature of your mail client, if it supports list unsubscribes.</p>
|
||||||
|
|
||||||
<p>If instead you'd like to confirm that you're willing to receive emails at this address, you can do so by clicking below:</p>
|
<p>If instead you'd like to confirm that you're willing to receive emails at this address, you can do so by clicking below:</p>
|
||||||
|
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
<a href="{{.URLSubscribe}}" class="button">I want emails from Report Mosquitoes Online</a>
|
<a href="{{.C.URLSubscribe}}" class="button">I want emails from Report Mosquitoes Online</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>This email was sent to you because you or someone else gave your email address to Report Mosquitoes Online.</p>
|
<p>This email was sent to you because you or someone else gave your email address to Report Mosquitoes Online.</p>
|
||||||
<p>If you no longer wish to receive these updates, <a href="{{.URLUnsubscribe}}">click here to unsubscribe</a>.</p>
|
<p>If you no longer wish to receive these updates, <a href="{{.C.URLUnsubscribe}}">click here to unsubscribe</a>.</p>
|
||||||
<p>© 2026 Gleipnir LLC. All rights reserved.</p>
|
<p>© 2026 Gleipnir LLC. All rights reserved.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
We're sending you this email because it's the first time we've gotten this email address ({{.Destination}}).
|
We're sending you this email because it's the first time we've gotten this email address ({{.C.Destination}}).
|
||||||
If you'd rather not receive emails from us you can reply with "Unsubscribe" in the subject or body of the email. You can also use the "Unsubscribe" feature of your mail client, if it supports list unsubscribes.
|
If you'd rather not receive emails from us you can reply with "Unsubscribe" in the subject or body of the email. You can also use the "Unsubscribe" feature of your mail client, if it supports list unsubscribes.
|
||||||
If instead you'd like to confirm that you're willing to receive emails at this address, you can do so by openining the following URL in a web browser: {{.URLSubscribe}}. You can also confirm your willingness by replying to this email with 'Confirm' in the subject on the body of the email.
|
If instead you'd like to confirm that you're willing to receive emails at this address, you can do so by openining the following URL in a web browser: {{.C.URLSubscribe}}. You can also confirm your willingness by replying to this email with 'Confirm' in the subject on the body of the email.
|
||||||
|
|
||||||
Thank you,
|
Thank you,
|
||||||
Report Mosquitoes Online
|
Report Mosquitoes Online
|
||||||
|
|
|
||||||
|
|
@ -64,35 +64,37 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
{{if not .IsBrowser}}
|
||||||
<div class="view-browser">
|
<div class="view-browser">
|
||||||
Email not displaying correctly? <a href="{{.URLViewInBrowser}}">View it in your browser</a>
|
Email not displaying correctly? <a href="{{.C.URLViewInBrowser}}">View it in your browser</a>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<!-- Logo Placeholder -->
|
<!-- Logo Placeholder -->
|
||||||
<img src="{{.URLLogo}}" alt="Report Mosquitoes Online Logo" class="logo">
|
<img src="{{.C.URLLogo}}" alt="Report Mosquitoes Online Logo" class="logo">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>Thank You for Your Report</h1>
|
<h1>Thank You for Your Report</h1>
|
||||||
|
|
||||||
<p>We've received your mosquito report {{.ReportIDStr}}. Thanks! We appreciate you taking the time to submit it.</p>
|
<p>We've received your mosquito report {{.C.ReportIDStr}}. Thanks! We appreciate you taking the time to submit it.</p>
|
||||||
|
|
||||||
<p>You can check the current status of your report at any time by clicking the button below:</p>
|
<p>You can check the current status of your report at any time by clicking the button below:</p>
|
||||||
|
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
<a href="{{.URLReportStatus}}" class="button">View Report Status</a>
|
<a href="{{.C.URLReportStatus}}" class="button">View Report Status</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>We'll send you additional updates as work is scheduled and completed.</p>
|
<p>We'll send you additional updates as work is scheduled and completed.</p>
|
||||||
|
|
||||||
<p>If you have any questions or need further assistance, please don't hesitate to contact us by replying to this email.</p>
|
<p>If you have any questions or need further assistance, please don't hesitate to contact us by replying to this email.</p>
|
||||||
<p>You can unsubscribe from notifications about this report by clicking <a hrep="{{.URLReportUnsubscribe}}">here</a></p>
|
<p>You can unsubscribe from notifications about this report by clicking <a hrep="{{.C.URLReportUnsubscribe}}">here</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>This email was sent to you because you requested updates on your mosquito nuisance report.</p>
|
<p>This email was sent to you because you requested updates on your mosquito nuisance report.</p>
|
||||||
<p>If you no longer wish to receive these updates, <a href="{{.URLReportUnsubscribe}}">click here to unsubscribe</a>.</p>
|
<p>If you no longer wish to receive these updates, <a href="{{.C.URLReportUnsubscribe}}">click here to unsubscribe</a>.</p>
|
||||||
<p>© 2026 Gleipnir LLC. All rights reserved.</p>
|
<p>© 2026 Gleipnir LLC. All rights reserved.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
We've received your mosquito report. Thanks! We appreciate you taking the time to submit it.
|
We've received your mosquito report. Thanks! We appreciate you taking the time to submit it.
|
||||||
|
|
||||||
You can check the current status of your report at any time at {{.URLReportStatus}}
|
You can check the current status of your report at any time at {{.C.URLReportStatus}}
|
||||||
|
|
||||||
We'll send you additional updates as work is scheduled and completed.
|
We'll send you additional updates as work is scheduled and completed.
|
||||||
|
|
||||||
If you have any questions or need further assistance, please don't hesitate to contact us by replying to this email.
|
If you have any questions or need further assistance, please don't hesitate to contact us by replying to this email.
|
||||||
|
|
||||||
If you no longer wish to receive these updates, navigate your browser to {{.URLReportUnsubscribe}} to unsubscribe.
|
If you no longer wish to receive these updates, navigate your browser to {{.C.URLReportUnsubscribe}} to unsubscribe.
|
||||||
|
|
|
||||||
24
rmo/template/email-subscribe-confirm.html
Normal file
24
rmo/template/email-subscribe-confirm.html
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{{template "base.html" .}}
|
||||||
|
|
||||||
|
{{define "title"}}Main{{end}}
|
||||||
|
{{define "extraheader"}}
|
||||||
|
{{end}}
|
||||||
|
{{define "content"}}
|
||||||
|
<!-- Main Content -->
|
||||||
|
<main>
|
||||||
|
<section class="py-2 bg-primary text-white">
|
||||||
|
<div class="banner-container d-flex justify-content-center">
|
||||||
|
<img class="banner" src="/static/img/rmo/banner.jpg"/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="py-3 row text-center">
|
||||||
|
<div class="container">
|
||||||
|
<h1>Thanks!</h1>
|
||||||
|
<p>You've allowed emails from Report Mosquitoes Online to {{.Email}}.</p>
|
||||||
|
<p>Go ahead and close this page/tab/window whenever you're ready...</p>
|
||||||
|
<p>...or maybe <a href="/">check out the site</a></p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
{{end}}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue