-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsystem_emails.go
More file actions
813 lines (753 loc) · 36.1 KB
/
Copy pathsystem_emails.go
File metadata and controls
813 lines (753 loc) · 36.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
package email
import (
"fmt"
"html"
"html/template"
"net/url"
"strings"
"time"
"github.com/samber/lo"
"github.com/theopenlane/newman"
"github.com/theopenlane/newman/render"
"github.com/theopenlane/core/internal/integrations/definitions/email/themes"
"github.com/theopenlane/core/internal/integrations/providerkit"
"github.com/theopenlane/core/internal/integrations/types"
)
// defaultHeader returns the standard header block used by all system emails
func defaultHeader(cfg RuntimeEmailConfig) render.HeaderBlock {
if cfg.HeaderLogoURL == "" {
return render.HeaderBlock{}
}
return render.HeaderBlock{Logo: &render.ContentIcon{Src: cfg.HeaderLogoURL, Alt: cfg.CompanyName}}
}
// baseTheme is the shared theme used by all email operations
var baseTheme = themes.Base
// Trust center / questionnaire button colors matching the original teal theme
const (
tcButtonColor = "#3fc2b4"
tcButtonTextColor = "#ffffff"
)
// ndaApprovalRequestPath is the console path where an approver reviews pending NDA requests
const ndaApprovalRequestPath = "/trust-center/NDAs"
// Brand palette colors sourced from the Openlane web design system (global.css)
const (
brandDarkGreen = "#0f3d3a" // lightened from --color-brand-950 (#092a2a)
brandTeal = "#3fc2b4" // --color-brand-400
brandLight100 = "#d1f6ee" // --color-brand-100
)
// applySystemBranding applies the default Openlane system email color treatment
func applySystemBranding(cfg RuntimeEmailConfig) RuntimeEmailConfig {
cfg.HeroBackgroundColor = brandDarkGreen
cfg.HeadingColor = "#ffffff"
cfg.TextColor = brandLight100
cfg.FooterTextColor = "#14171e"
cfg.ButtonColor = brandTeal
cfg.ButtonTextColor = brandDarkGreen
return cfg
}
// applyCalloutBranding applies the Openlane system email treatment for emails with a callout section
func applyCalloutBranding(cfg RuntimeEmailConfig) RuntimeEmailConfig {
cfg.ButtonColor = brandTeal
cfg.ButtonTextColor = brandDarkGreen
return cfg
}
// calloutStyle returns a render.Style that brands the callout box with the dark green background and white text
func calloutStyle() render.Style {
return render.Style{
BackgroundColor: brandDarkGreen,
PrimaryColor: "#ffffff",
TextColor: "#ffffff",
}
}
// tokenURL constructs a product URL with a query-encoded token parameter
func tokenURL(base, path, token string) string {
return base + path + "?token=" + url.QueryEscape(token)
}
// VerifyEmailRequest is the input for the email verification operation
type VerifyEmailRequest struct {
RecipientInfo
// Token is the email verification token appended to the verify URL
Token string `json:"token" jsonschema:"required,description=Email verification token"`
}
// WelcomeRequest is the input for the welcome email operation
type WelcomeRequest struct {
RecipientInfo
}
// InviteRequest is the input for the organization invite operation
type InviteRequest struct {
RecipientInfo
// InviterName is the name of the person who sent the invite
InviterName string `json:"inviter_name" jsonschema:"required,description=Name of the person sending the invite"`
// OrgName is the organization being invited to
OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
// Role is the invited role
Role string `json:"role,omitempty" jsonschema:"description=Invited role"`
// Token is the invite token appended to the invite URL
Token string `json:"token" jsonschema:"required,description=Invite token"`
}
// InviteJoinedRequest is the input for the invite-accepted notification
type InviteJoinedRequest struct {
RecipientInfo
// OrgName is the organization the user joined
OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
}
// PasswordResetEmailRequest is the input for the password reset request operation
type PasswordResetEmailRequest struct {
RecipientInfo
// Token is the password reset token appended to the reset URL
Token string `json:"token" jsonschema:"required,description=Password reset token"`
}
// PasswordResetSuccessRequest is the input for the password reset confirmation operation
type PasswordResetSuccessRequest struct {
RecipientInfo
}
// SubscribeRequest is the input for the subscription verification operation
type SubscribeRequest struct {
RecipientInfo
// OrgName is the display name of the subscribing organization
OrgName string `json:"org_name" jsonschema:"required,description=Organization display name"`
// Token is the subscriber verification token appended to the verify URL
Token string `json:"token" jsonschema:"required,description=Subscriber verification token"`
}
// VerifyBillingRequest is the input for the billing email verification operation
type VerifyBillingRequest struct {
RecipientInfo
// Token is the billing verification token appended to the verify URL
Token string `json:"token" jsonschema:"required,description=Billing verification token"`
}
// TrustCenterNDARequestEmail is the input for the trust center NDA signing request.
// Callers may pass either the pre-built NDAURL or the RequestID + TrustCenterID pair;
// when NDAURL is empty the operation resolves it from RequestID and TrustCenterID.
// OrgName is resolved from TrustCenterID when empty
type TrustCenterNDARequestEmail struct {
RecipientInfo
// OrgName is the organization requesting the NDA; resolved from TrustCenterID when empty
OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
// RequestID is the NDA request identifier used for JWT subject construction
RequestID string `json:"requestId,omitempty" jsonschema:"description=NDA request ID for token generation"`
// TrustCenterID is the trust center identifier used for URL construction
TrustCenterID string `json:"trustCenterId,omitempty" jsonschema:"description=Trust center ID for URL construction"`
// NDAURL is the direct URL to the NDA signing page; when empty the operation constructs it from RequestID and TrustCenterID
NDAURL string `json:"ndaUrl,omitempty" jsonschema:"description=NDA signing URL"`
}
// TrustCenterNDASignedEmail is the input for the NDA signed confirmation.
// Callers may pass either the pre-built TrustCenterURL or the RequestID + TrustCenterID pair;
// when TrustCenterURL is empty the operation resolves it (with an auth token) from RequestID and TrustCenterID.
// OrgName is resolved from TrustCenterID when empty
type TrustCenterNDASignedEmail struct {
RecipientInfo
// OrgName is the organization whose NDA was signed; resolved from TrustCenterID when empty
OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
// TrustCenterURL is the URL to the trust center; when empty the operation constructs it with an auth token from RequestID and TrustCenterID
TrustCenterURL string `json:"trust_center_url,omitempty" jsonschema:"description=Trust center URL"`
// RequestID is the NDA request identifier used for JWT subject construction
RequestID string `json:"request_id,omitempty" jsonschema:"description=NDA request ID for token generation"`
// TrustCenterID is the trust center identifier used for URL construction
TrustCenterID string `json:"trust_center_id,omitempty" jsonschema:"description=Trust center ID for URL construction"`
// AttachmentFilename is the filename for the signed NDA attachment
AttachmentFilename string `json:"attachment_filename,omitempty" jsonschema:"description=Signed NDA attachment filename"`
// AttachmentData is the raw content of the signed NDA attachment
AttachmentData []byte `json:"attachment_data,omitempty" jsonschema:"description=Signed NDA attachment content"`
}
// TrustCenterAuthEmail is the input for trust center access authentication.
// Callers may pass either the pre-built AuthURL or the RequestID + TrustCenterID pair;
// when AuthURL is empty the operation resolves it from RequestID and TrustCenterID.
// OrgName is resolved from TrustCenterID when empty
type TrustCenterAuthEmail struct {
RecipientInfo
// OrgName is the organization whose trust center is being accessed; resolved from TrustCenterID when empty
OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
// RequestID is the NDA request identifier used for JWT subject construction
RequestID string `json:"requestId,omitempty" jsonschema:"description=NDA request ID for token generation"`
// TrustCenterID is the trust center identifier used for URL construction
TrustCenterID string `json:"trustCenterId,omitempty" jsonschema:"description=Trust center ID for URL construction"`
// AuthURL is the authentication URL for trust center access; when empty the operation constructs it from RequestID and TrustCenterID
AuthURL string `json:"authUrl,omitempty" jsonschema:"description=Trust center auth URL"`
}
// QuestionnaireAuthEmail is the input for questionnaire access authentication
type QuestionnaireAuthEmail struct {
RecipientInfo
// OrgName is the name of the organization sending the questionnaire; resolved from auth context when empty
OrgName string `json:"org_name,omitempty" jsonschema:"description=Organization name"`
// AssessmentName is the name of the assessment/questionnaire
AssessmentName string `json:"assessment_name" jsonschema:"required,description=Assessment name"`
// AuthURL is the authentication URL for questionnaire access
AuthURL string `json:"auth_url" jsonschema:"required,description=Questionnaire auth URL"`
}
// BillingEmailChangedEmail is the input for the billing email change notification
type BillingEmailChangedEmail struct {
RecipientInfo
// OrgName is the organization whose billing email changed
OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
// OldBillingEmail is the previous billing email address
OldBillingEmail string `json:"old_billing_email" jsonschema:"required,description=Previous billing email"`
// NewBillingEmail is the new billing email address
NewBillingEmail string `json:"new_billing_email" jsonschema:"required,description=New billing email"`
// ChangedAt is the timestamp of the change
ChangedAt time.Time `json:"changed_at" jsonschema:"required,description=Timestamp of the change"`
}
// OrgDeletionNoticeEmail is the input for the organization deletion notice operation
type OrgDeletionNoticeEmail struct {
RecipientInfo
// OrgName is the name of the organization scheduled for deletion
OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
// DeletionDate is the date the organization will be deleted
DeletionDate time.Time `json:"deletion_date" jsonschema:"required,description=Scheduled deletion date"`
}
// TrustCenterNDAApprovalRequestEmail is the input for notifying the organization's
// designated approver that an NDA request is pending approval.
type TrustCenterNDAApprovalRequestEmail struct {
RecipientInfo
// OrgName is the organization whose trust center received the NDA request
OrgName string `json:"org_name" jsonschema:"required,description=Organization name"`
// RequesterName is the name of the person requesting access
RequesterName string `json:"requester_name,omitempty" jsonschema:"description=Name of the requester"`
// RequesterEmail is the email address of the person requesting access
RequesterEmail string `json:"requester_email" jsonschema:"required,description=Email address of the requester"`
}
// --- Schema + operation ref vars ---
var (
verifyEmailSchema, VerifyEmailOp = providerkit.OperationSchema[VerifyEmailRequest]() //nolint:revive
welcomeSchema, WelcomeOp = providerkit.OperationSchema[WelcomeRequest]() //nolint:revive
inviteSchema, InviteOp = providerkit.OperationSchema[InviteRequest]() //nolint:revive
inviteJoinedSchema, InviteJoinedOp = providerkit.OperationSchema[InviteJoinedRequest]() //nolint:revive
resetRequestSchema, ResetRequestOp = providerkit.OperationSchema[PasswordResetEmailRequest]() //nolint:revive
resetSuccessSchema, ResetSuccessOp = providerkit.OperationSchema[PasswordResetSuccessRequest]() //nolint:revive
subscribeSchema, SubscribeOp = providerkit.OperationSchema[SubscribeRequest]() //nolint:revive
verifyBillingSchema, VerifyBillingOp = providerkit.OperationSchema[VerifyBillingRequest]() //nolint:revive
tcNDARequestSchema, TCNDARequestOp = providerkit.OperationSchema[TrustCenterNDARequestEmail]() //nolint:revive
tcNDASignedSchema, TCNDASignedOp = providerkit.OperationSchema[TrustCenterNDASignedEmail]() //nolint:revive
tcAuthSchema, TCAuthOp = providerkit.OperationSchema[TrustCenterAuthEmail]() //nolint:revive
questionnaireAuthSchema, QuestionnaireAuthOp = providerkit.OperationSchema[QuestionnaireAuthEmail]() //nolint:revive
billingEmailChangedSchema, BillingEmailChangedOp = providerkit.OperationSchema[BillingEmailChangedEmail]() //nolint:revive
orgDeletionNoticeSchema, OrgDeletionNoticeOp = providerkit.OperationSchema[OrgDeletionNoticeEmail]() //nolint:revive
tcNDAApprovalRequestSchema, TCNDAApprovalRequestOp = providerkit.OperationSchema[TrustCenterNDAApprovalRequestEmail]() //nolint:revive
)
// --- Email operation definitions ---
var _ = RegisterEmailOperation(Operation[VerifyEmailRequest]{
Op: VerifyEmailOp, Schema: verifyEmailSchema, Theme: baseTheme,
Description: "System email prompting a new user to verify their email address",
Subject: func(cfg RuntimeEmailConfig, _ VerifyEmailRequest) string {
return "Please verify your email address to login to " + cfg.CompanyName
},
Build: func(cfg RuntimeEmailConfig, req VerifyEmailRequest) render.ContentBody {
verifyURL := tokenURL(cfg.ProductURL, "/verify", req.Token)
return render.ContentBody{
Preheader: "Verify Your Email Address",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "Verify Your Email Address",
Intros: render.IntrosBlock{
Paragraphs: []string{
"Welcome to " + cfg.CompanyName + " - where compliance isn't just a checkbox.",
"Before you get started, let's make sure it's really you. Click below to verify your email:",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Confirm Email", Link: verifyURL},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"This link expires in 7 days - but don't worry, if it does, you'll get a fresh one when you try to verify later.",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ VerifyEmailRequest) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[WelcomeRequest]{
Op: WelcomeOp, Schema: welcomeSchema, Theme: baseTheme,
Description: "System welcome email delivered after account signup",
Subject: func(cfg RuntimeEmailConfig, _ WelcomeRequest) string {
return "Welcome to " + cfg.CompanyName + "!"
},
Build: func(cfg RuntimeEmailConfig, req WelcomeRequest) render.ContentBody {
return render.ContentBody{
Preheader: "We're thrilled to have you here!",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "Ready to get started?",
Intros: render.IntrosBlock{
Paragraphs: []string{
"At " + cfg.CompanyName + ", we're working to develop a cutting-edge cybersecurity and compliance automation solution to help organizations of all sizes and industries secure their systems, navigate the increasingly complex web of privacy laws and regulations, ensure continuous compliance, manage risks, and get ahead of evolving cyber threats.",
},
},
Callout: &render.Callout{
Title: "Here's how to get started:",
Style: calloutStyle(),
Items: []template.HTML{
"Go through our onboarding process to get a personalized experience",
"Setup a test program to see all the features our platform has to offer",
"Checkout our " + render.LinkWithColor(cfg.DocsURL+"/docs/platform/quickstartguide", "quickstart guide", brandLight100) + " for helpful resources",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Get Started", Link: cfg.ProductURL},
}},
}
},
Config: func(cfg RuntimeEmailConfig, _ WelcomeRequest) RuntimeEmailConfig {
return applyCalloutBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[InviteRequest]{
Op: InviteOp, Schema: inviteSchema, Theme: baseTheme,
Description: "System email inviting a user to join an organization",
Subject: func(cfg RuntimeEmailConfig, req InviteRequest) string {
return "Join Your Teammate " + req.InviterName + " on " + cfg.CompanyName + "!"
},
Build: func(cfg RuntimeEmailConfig, req InviteRequest) render.ContentBody {
inviteURL := tokenURL(cfg.ProductURL, "/invite", req.Token)
inviteIntro := template.HTML("You're in - let's build trust without the busywork. "+html.EscapeString(req.InviterName)+" has invited you to collaborate in "+html.EscapeString(cfg.CompanyName)+", as part of the ") + //nolint:gosec // all user input is escaped via html.EscapeString
render.Bold(req.OrgName) + " organization"
if req.Role != "" {
inviteIntro += template.HTML(" with the role of " + html.EscapeString(strings.ToUpper(req.Role))) //nolint:gosec // role is escaped
}
inviteIntro += "."
return render.ContentBody{
Preheader: "You've been invited to join " + cfg.CompanyName,
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "You've been invited to join " + cfg.CompanyName + "!",
Intros: render.IntrosBlock{
Unsafe: []template.HTML{
inviteIntro,
"To get started (and verify your email), click the link below:",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Accept Invite", Link: inviteURL},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"This link expires in 7 days - but don't worry, if it does, you'll get a fresh one when you try to verify later.",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ InviteRequest) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[InviteJoinedRequest]{
Op: InviteJoinedOp, Schema: inviteJoinedSchema, Theme: baseTheme,
Description: "System notification confirming an invited user has joined an organization",
Subject: func(cfg RuntimeEmailConfig, _ InviteJoinedRequest) string {
return "You've been added to an Organization on " + cfg.CompanyName
},
Build: func(cfg RuntimeEmailConfig, req InviteJoinedRequest) render.ContentBody {
return render.ContentBody{
Preheader: "You're in - welcome to " + req.OrgName + " on " + cfg.CompanyName + "!",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "You're in - welcome to " + req.OrgName + " on " + cfg.CompanyName + "!",
Intros: render.IntrosBlock{
Paragraphs: []string{
"Welcome to " + cfg.CompanyName + " - we're excited to have you on board with " + req.OrgName + "!",
"Ditch the spreadsheets, and embrace the pipeline with a faster, cleaner way to automate compliance, manage risk, and stay ahead of security threats - without the manual overhead.",
},
},
Callout: &render.Callout{
Title: "Here's how to get started:",
Ordered: true,
Style: calloutStyle(),
Items: []template.HTML{
"Complete the onboarding flow to tailor your experience",
"Explore any active " + render.LinkWithColor(cfg.ProductURL+"/programs", "programs", brandLight100) + " your team is running",
"Checkout our " + render.LinkWithColor(cfg.DocsURL, "quickstart guide", brandLight100) + " for helpful resources",
},
},
Outros: render.OutrosBlock{
Paragraphs: []string{
"When you're ready, hop into the platform and start exploring:",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Get Started", Link: cfg.ProductURL},
}},
}
},
Config: func(cfg RuntimeEmailConfig, _ InviteJoinedRequest) RuntimeEmailConfig {
return applyCalloutBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[PasswordResetEmailRequest]{
Op: ResetRequestOp, Schema: resetRequestSchema, Theme: baseTheme,
Description: "System email delivering a password reset link to a user",
Subject: func(cfg RuntimeEmailConfig, _ PasswordResetEmailRequest) string {
return cfg.CompanyName + " Password Reset - Action Required"
},
Build: func(cfg RuntimeEmailConfig, req PasswordResetEmailRequest) render.ContentBody {
resetURL := tokenURL(cfg.ProductURL, "/password-reset", req.Token)
return render.ContentBody{
Preheader: "Reset your " + cfg.CompanyName + " password",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "Reset your " + cfg.CompanyName + " password",
Intros: render.IntrosBlock{
Paragraphs: []string{
"We received a request to reset your " + cfg.CompanyName + " password.",
"If that was you, no problem - just click the button below to set a new one:",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Password Reset", Link: resetURL},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"This link will expire in 15 minutes to keep things secure.",
"If you didn't request a password reset, you can safely ignore this email.",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ PasswordResetEmailRequest) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[PasswordResetSuccessRequest]{
Op: ResetSuccessOp, Schema: resetSuccessSchema, Theme: baseTheme,
Description: "System email confirming a successful password reset",
Subject: func(cfg RuntimeEmailConfig, _ PasswordResetSuccessRequest) string {
return cfg.CompanyName + " Password Reset Confirmation"
},
Build: func(cfg RuntimeEmailConfig, req PasswordResetSuccessRequest) render.ContentBody {
return render.ContentBody{
Preheader: "Your " + cfg.CompanyName + " password has been reset",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "Your " + cfg.CompanyName + " password has been reset",
Intros: render.IntrosBlock{
Paragraphs: []string{
"Your password was successfully updated. If you made this change, you're all set - no further action needed.",
"If you didn't request a password reset, please contact our support team right away at " + cfg.SupportEmail + ". Keeping your account secure is our top priority.",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ PasswordResetSuccessRequest) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[SubscribeRequest]{
Op: SubscribeOp, Schema: subscribeSchema, Theme: baseTheme,
Description: "System email confirming a subscriber's early access signup",
Subject: func(cfg RuntimeEmailConfig, _ SubscribeRequest) string {
return "You've been subscribed to " + cfg.CompanyName
},
Build: func(cfg RuntimeEmailConfig, req SubscribeRequest) render.ContentBody {
verifyURL := tokenURL(cfg.ProductURL, "/subscribe/verify", req.Token)
return render.ContentBody{
Preheader: "You're In - Early Access Secured! Thanks for your interest in our beta program.",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "You're In - Early Access Secured!",
Intros: render.IntrosBlock{
Paragraphs: []string{
"We're thrilled to have you as part of our early community. Your interest means the world to us as we work to build a cutting-edge solution. We can't wait to share it with you!",
"Please confirm your email address to ensure you receive all important updates about your early access.",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Confirm Email", Link: verifyURL},
}},
Callout: &render.Callout{
Title: "What to Expect Next:",
Style: calloutStyle(),
Items: []template.HTML{
"You'll hear from us soon - We'll email you as soon as your spot is ready.",
"Early access to beta features - Get a first look at everything we're building.",
"Help shape the future - Your feedback will directly influence the product.",
},
},
Outros: render.OutrosBlock{
Paragraphs: []string{
"Thank you for being part of this journey - we're excited to have you on board!",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ SubscribeRequest) RuntimeEmailConfig {
return applyCalloutBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[VerifyBillingRequest]{
Op: VerifyBillingOp, Schema: verifyBillingSchema, Theme: baseTheme,
Description: "System email prompting verification of the billing email on file",
Subject: func(cfg RuntimeEmailConfig, _ VerifyBillingRequest) string {
return "Please verify the billing email for " + cfg.CompanyName + " to ensure your account stays up to date"
},
Build: func(cfg RuntimeEmailConfig, req VerifyBillingRequest) render.ContentBody {
verifyURL := tokenURL(cfg.ProductURL, "/billing/verify", req.Token)
return render.ContentBody{
Preheader: "Verify Your Email Address",
Header: defaultHeader(cfg),
Name: req.FirstName,
Title: "Verify Your Billing Email Address",
Intros: render.IntrosBlock{
Paragraphs: []string{
"You're receiving this because the billing contact for your " + cfg.CompanyName + " account was just updated.",
"To help keep your account secure, please verify your email address by clicking the button below:",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Confirm Billing Email", Link: verifyURL},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"If you run into any issues, feel free to reach out at " + cfg.SupportEmail + ".",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ VerifyBillingRequest) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[TrustCenterNDARequestEmail]{
Op: TCNDARequestOp, Schema: tcNDARequestSchema, Theme: baseTheme,
Description: "System email requesting an NDA signature before granting trust center access",
PreHook: resolveTrustCenterNDARequestFields,
Subject: func(_ RuntimeEmailConfig, req TrustCenterNDARequestEmail) string {
return req.OrgName + " Trust Center NDA Request"
},
Build: func(cfg RuntimeEmailConfig, req TrustCenterNDARequestEmail) render.ContentBody {
return render.ContentBody{
Preheader: "Review and sign the NDA to access " + req.OrgName + "'s Trust Center",
Header: defaultHeader(cfg),
Title: "You requested access to " + req.OrgName + "'s Trust Center",
Intros: render.IntrosBlock{
Paragraphs: []string{
"To continue, please review and sign the Non-Disclosure Agreement (NDA). Once signed, you'll be granted access to protected Trust Center documents.",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Sign NDA", Link: req.NDAURL, Color: tcButtonColor, TextColor: tcButtonTextColor},
}},
}
},
})
var _ = RegisterEmailOperation(Operation[TrustCenterNDASignedEmail]{
Op: TCNDASignedOp, Schema: tcNDASignedSchema, Theme: baseTheme,
Description: "System email confirming a signed NDA and attaching the signed copy",
PreHook: resolveTrustCenterNDASignedFields,
Subject: func(_ RuntimeEmailConfig, req TrustCenterNDASignedEmail) string {
return req.OrgName + " Trust Center NDA Signed"
},
Build: func(cfg RuntimeEmailConfig, req TrustCenterNDASignedEmail) render.ContentBody {
return render.ContentBody{
Preheader: "Your NDA with " + req.OrgName + " is complete — access granted",
Header: defaultHeader(cfg),
Title: "Your NDA with " + req.OrgName + " has been signed",
Intros: render.IntrosBlock{
Paragraphs: []string{
"Thank you for signing the Non-Disclosure Agreement (NDA). You now have access to " + req.OrgName + "'s protected Trust Center documents.",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Visit Trust Center", Link: req.TrustCenterURL, Color: tcButtonColor, TextColor: tcButtonTextColor},
}},
}
},
MessageOptions: func(_ RuntimeEmailConfig, req TrustCenterNDASignedEmail) []newman.MessageOption {
if req.AttachmentFilename == "" || len(req.AttachmentData) == 0 {
return nil
}
return []newman.MessageOption{
newman.WithAttachment(newman.NewAttachment(req.AttachmentFilename, req.AttachmentData)),
}
},
})
var _ = RegisterEmailOperation(Operation[TrustCenterAuthEmail]{
Op: TCAuthOp, Schema: tcAuthSchema, Theme: baseTheme,
Description: "System email delivering a time-limited authentication link to a trust center",
PreHook: resolveTrustCenterAuthFields,
Subject: func(_ RuntimeEmailConfig, req TrustCenterAuthEmail) string {
return "Access " + req.OrgName + "'s Trust Center"
},
Build: func(cfg RuntimeEmailConfig, req TrustCenterAuthEmail) render.ContentBody {
return render.ContentBody{
Preheader: "Your secure link to " + req.OrgName + "'s Trust Center",
Header: defaultHeader(cfg),
Title: "Access " + req.OrgName + "'s Trust Center",
Intros: render.IntrosBlock{
Paragraphs: []string{
"You've been granted access to " + req.OrgName + "'s Trust Center. Click the button below to authenticate and view the available resources.",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Access Trust Center", Link: req.AuthURL, Color: tcButtonColor, TextColor: tcButtonTextColor},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"This authentication link provides secure, time-limited access and will expire after a short period for your security.",
},
},
}
},
})
var _ = RegisterEmailOperation(Operation[TrustCenterNDAApprovalRequestEmail]{
Op: TCNDAApprovalRequestOp, Schema: tcNDAApprovalRequestSchema, Theme: baseTheme,
Description: "System email notifying a designated approver that a trust center NDA request is pending approval",
Subject: func(cfg RuntimeEmailConfig, _ TrustCenterNDAApprovalRequestEmail) string {
return "Trust Center NDA Request Pending Approval in " + cfg.CompanyName
},
Build: func(cfg RuntimeEmailConfig, req TrustCenterNDAApprovalRequestEmail) render.ContentBody {
requester := req.RequesterEmail
if req.RequesterName != "" {
requester = req.RequesterName + " (" + req.RequesterEmail + ")"
}
return render.ContentBody{
Preheader: "An NDA request is pending approval for " + req.OrgName + "'s Trust Center",
Header: defaultHeader(cfg),
Title: "NDA request pending approval",
Intros: render.IntrosBlock{
Paragraphs: []string{
"A new request to access protected Trust Center materials is pending your approval.",
"Please review the NDA request and approve or deny access as appropriate.",
},
},
Dictionary: render.Dictionary{
Cells: []render.Cell{
{Key: "Organization", Value: req.OrgName},
{Key: "Requester", Value: requester},
},
},
Actions: []render.Action{{
Button: render.Button{
Text: "Review NDA Request",
Link: cfg.ProductURL + ndaApprovalRequestPath,
Color: tcButtonColor,
TextColor: tcButtonTextColor,
},
}},
}
},
})
var questionnaireAuthEmail = RegisterEmailOperation(Operation[QuestionnaireAuthEmail]{
Op: QuestionnaireAuthOp, Schema: questionnaireAuthSchema, Theme: baseTheme,
Description: "System email delivering a time-limited authentication link to a questionnaire",
PreHook: resolveQuestionnaireOrgName,
Subject: func(_ RuntimeEmailConfig, req QuestionnaireAuthEmail) string {
return "Access " + req.AssessmentName + " Questionnaire from " + req.OrgName
},
Build: func(cfg RuntimeEmailConfig, req QuestionnaireAuthEmail) render.ContentBody {
return render.ContentBody{
Preheader: req.AssessmentName + " — complete your questionnaire from " + req.OrgName,
Header: defaultHeader(cfg),
Title: req.OrgName + " sent you an assessment to complete",
Intros: render.IntrosBlock{
Paragraphs: []string{
req.OrgName + " has shared a form (" + req.AssessmentName + ") for you to complete. Click the button below to access it.",
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Access Questionnaire", Link: req.AuthURL, Color: tcButtonColor, TextColor: tcButtonTextColor},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"This authentication link provides secure, time-limited access and will expire after a short period for your security.",
},
},
}
},
MessageOptions: func(cfg RuntimeEmailConfig, _ QuestionnaireAuthEmail) []newman.MessageOption {
if cfg.QuestionnaireEmail == "" {
return nil
}
return []newman.MessageOption{
newman.WithFrom(cfg.QuestionnaireEmail),
}
},
})
var _ = RegisterEmailOperation(Operation[BillingEmailChangedEmail]{
Op: BillingEmailChangedOp, Schema: billingEmailChangedSchema, Theme: baseTheme,
Description: "System notification confirming a change to the billing email on file",
Subject: func(_ RuntimeEmailConfig, req BillingEmailChangedEmail) string {
return "Billing Email Changed for " + req.OrgName
},
Build: func(cfg RuntimeEmailConfig, req BillingEmailChangedEmail) render.ContentBody {
return render.ContentBody{
Preheader: "Billing Email Changed",
Header: defaultHeader(cfg),
Title: "Billing Email Changed",
Intros: render.IntrosBlock{
Paragraphs: []string{
"This email is to confirm that the billing email for " + req.OrgName + " has been changed.",
},
},
Dictionary: render.Dictionary{
Cells: []render.Cell{
{Key: "Previous email", Value: req.OldBillingEmail},
{Key: "New email", Value: req.NewBillingEmail},
{Key: "Time of action", Value: req.ChangedAt.Format("January 2, 2006 at 3:04 PM MST")},
},
},
Outros: render.OutrosBlock{
Unsafe: []template.HTML{
"If you made this change, no further action is required.",
template.HTML(`If you did not make this change, please contact our support team immediately at <a href="mailto:` + cfg.SupportEmail + `" style="color:rgb(63,118,255);text-decoration-line:none" target="_blank">` + cfg.SupportEmail + `</a>.`), //nolint:gosec // SupportEmail is a system config value, not user input
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ BillingEmailChangedEmail) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
var _ = RegisterEmailOperation(Operation[OrgDeletionNoticeEmail]{
Op: OrgDeletionNoticeOp, Schema: orgDeletionNoticeSchema, Theme: baseTheme,
Description: "System notification that an organization has been scheduled for deletion due to missing payment method",
Subject: func(_ RuntimeEmailConfig, req OrgDeletionNoticeEmail) string {
return fmt.Sprintf("Organization Deletion Notice for %s", req.OrgName)
},
Build: func(cfg RuntimeEmailConfig, req OrgDeletionNoticeEmail) render.ContentBody {
return render.ContentBody{
Preheader: "Your organization " + req.OrgName + " has been scheduled for deletion",
Header: defaultHeader(cfg),
Title: "Organization Deletion Notice",
Intros: render.IntrosBlock{
Paragraphs: []string{
"This email is to notify you that your organization " + req.OrgName + " has been scheduled for deletion.",
},
},
Dictionary: render.Dictionary{
Cells: []render.Cell{
{Key: "Scheduled deletion date", Value: req.DeletionDate.Format("January 2, 2006")},
},
},
Actions: []render.Action{{
Button: render.Button{Text: "Add Payment Method", Link: cfg.ProductURL + "/billing"},
}},
Outros: render.OutrosBlock{
Paragraphs: []string{
"If you want to keep your account, please add a payment method before the scheduled deletion date.",
"If you believe this was done in error, please contact our support team immediately at " + cfg.SupportEmail + ".",
},
},
}
},
Config: func(cfg RuntimeEmailConfig, _ OrgDeletionNoticeEmail) RuntimeEmailConfig {
return applySystemBranding(cfg)
},
})
// AllEmailOperations returns all system email operation registrations for wiring into the builder
func AllEmailOperations() []types.OperationRegistration {
return lo.Map(dispatchers, func(d Dispatcher, _ int) types.OperationRegistration {
return d.Registration()
})
}
// CustomerSelectableDispatchers returns the dispatchers explicitly marked as customer-selectable
func CustomerSelectableDispatchers() []Dispatcher {
return lo.Filter(dispatchers, func(d Dispatcher, _ int) bool {
cs := d.Registration().CustomerSelectable
return cs != nil && *cs
})
}
// DispatcherByKey resolves a registered email dispatcher by its catalog key
func DispatcherByKey(key string) (Dispatcher, bool) {
d, ok := dispatcherIndex[key]
return d, ok
}