From 470e9ddfe7bbedc0c12186eafc81035d93cb162a Mon Sep 17 00:00:00 2001
From: Vishal Dalwadi <51291657+VishalDalwadi@users.noreply.github.com>
Date: Thu, 24 Oct 2024 15:22:55 +0530
Subject: [PATCH] feat(go): update email template. (#3150)
* feat(go): update email template.
* feat(go): update email template.
* feat(go): update email template.
* feat(go): update email template.
* feat(go): update email template.
* feat(go): update email template.
* feat(go): update email template.
---
pro/controllers/users.go | 5 +-
pro/email/invite.go | 83 +++--
pro/email/utils.go | 652 ++++++++-------------------------------
3 files changed, 172 insertions(+), 568 deletions(-)
diff --git a/pro/controllers/users.go b/pro/controllers/users.go
index d5ea4ddb..87d69e4c 100644
--- a/pro/controllers/users.go
+++ b/pro/controllers/users.go
@@ -250,8 +250,9 @@ func inviteUsers(w http.ResponseWriter, r *http.Request) {
// Set E-Mail body. You can set plain text or html with text/html
e := email.UserInvitedMail{
- BodyBuilder: &email.EmailBodyBuilderWithH1HeadlineAndImage{},
- InviteURL: invite.InviteURL,
+ BodyBuilder: &email.EmailBodyBuilderWithH1HeadlineAndImage{},
+ InviteURL: invite.InviteURL,
+ PlatformRoleID: invite.PlatformRoleID,
}
n := email.Notification{
RecipientMail: invite.Email,
diff --git a/pro/email/invite.go b/pro/email/invite.go
index 86018462..721b3387 100644
--- a/pro/email/invite.go
+++ b/pro/email/invite.go
@@ -2,65 +2,60 @@ package email
import (
"fmt"
+ "github.com/gravitl/netmaker/models"
+ proLogic "github.com/gravitl/netmaker/pro/logic"
"github.com/gravitl/netmaker/servercfg"
)
// UserInvitedMail - mail for users that are invited to a tenant
type UserInvitedMail struct {
- BodyBuilder EmailBodyBuilder
- InviteURL string
+ BodyBuilder EmailBodyBuilder
+ InviteURL string
+ PlatformRoleID string
}
// GetSubject - gets the subject of the email
func (UserInvitedMail) GetSubject(info Notification) string {
- return "You're invited to join Netmaker"
+ return "Connect to Your Secure Network Using Netmaker"
}
// GetBody - gets the body of the email
func (invite UserInvitedMail) GetBody(info Notification) string {
+ downloadLink := "https://www.netmaker.io/download"
+ supportEmail := "support@netmaker.io"
+
+ dashboardURL := fmt.Sprintf("https://dashboard.%s", servercfg.GetNmBaseDomain())
if servercfg.DeployedByOperator() {
- return invite.BodyBuilder.
- WithParagraph("Hi there,").
- WithParagraph("
").
- WithParagraph("Great news! Your colleague has invited you to join their Netmaker SaaS Tenant.").
- WithParagraph("Click the button to accept your invitation:").
- WithParagraph("
").
- WithParagraph(fmt.Sprintf("Accept Invitation", invite.InviteURL)).
- WithParagraph("
").
- WithParagraph("Why you'll love Netmaker:").
- WithParagraph("
").
- WithParagraph("- Blazing-fast connections with our WireGuard®-powered mesh VPN
").
- WithParagraph("- Seamless multi-cloud and hybrid-cloud networking
").
- WithParagraph("- Automated Kubernetes networking across any infrastructure
").
- WithParagraph("- Enterprise-grade security with simple management
").
- WithParagraph("
").
- WithParagraph("Got questions? Our team is here to help you every step of the way.").
- WithParagraph("
").
- WithParagraph("Welcome aboard,").
- WithParagraph("The Netmaker Team
").
- WithParagraph("P.S. Curious to learn more before accepting? Check out our quick start tutorial at netmaker.io/tutorials").
- Build()
+ dashboardURL = fmt.Sprintf("%s/dashboard?tenant_id=%s", proLogic.GetAccountsUIHost(), servercfg.GetNetmakerTenantID())
}
- return invite.BodyBuilder.
- WithParagraph("Hi there,").
- WithParagraph("
").
- WithParagraph("Great news! Your colleague has invited you to join their Netmaker network.").
- WithParagraph("Click the button to accept your invitation:").
- WithParagraph("
").
- WithParagraph(fmt.Sprintf("Accept Invitation", invite.InviteURL)).
- WithParagraph("
").
- WithParagraph("Why you'll love Netmaker:").
- WithParagraph("").
- WithParagraph("- Blazing-fast connections with our WireGuard®-powered mesh VPN
").
- WithParagraph("- Seamless multi-cloud and hybrid-cloud networking
").
- WithParagraph("- Automated Kubernetes networking across any infrastructure
").
- WithParagraph("- Enterprise-grade security with simple management
").
- WithParagraph("
").
- WithParagraph("Got questions? Our team is here to help you every step of the way.").
- WithParagraph("
").
- WithParagraph("Welcome aboard,").
- WithParagraph("The Netmaker Team
").
- WithParagraph("P.S. Curious to learn more before accepting? Check out our quick start tutorial at netmaker.io/tutorials").
+ content := invite.BodyBuilder.
+ WithParagraph("Hi,").
+ WithParagraph("You've been invited to access a secure network via Netmaker's Remote Access Client (RAC). Follow these simple steps to get connected:").
+ WithHtml("").
+ WithHtml(fmt.Sprintf("- Click here to accept your invitation and setup your account.
", invite.InviteURL)).
+ WithHtml("
").
+ WithHtml(fmt.Sprintf("- Download the Remote Access Client (RAC).
", downloadLink))
+
+ if invite.PlatformRoleID == models.AdminRole.String() || invite.PlatformRoleID == models.PlatformUser.String() {
+ content = content.
+ WithHtml("
").
+ WithHtml(fmt.Sprintf("- Access the Netmaker Dashboard - use it to manage your network settings and view network status.
", dashboardURL))
+ }
+
+ connectionID := servercfg.GetNetmakerTenantID()
+ if !servercfg.DeployedByOperator() {
+ connectionID = fmt.Sprintf("api.%s", servercfg.GetNmBaseDomain())
+ }
+
+ return content.
+ WithHtml("
").
+ WithParagraph("Important Information:").
+ WithHtml("").
+ WithHtml(fmt.Sprintf("- When connecting through RAC, please enter your server connection ID: %s.
", connectionID)).
+ WithHtml("
").
+ WithParagraph(fmt.Sprintf("If you have any questions or need assistance, please contact our support team at %s.", supportEmail, supportEmail)).
+ WithParagraph("Best Regards,").
+ WithParagraph("The Netmaker Team").
Build()
}
diff --git a/pro/email/utils.go b/pro/email/utils.go
index b689a8be..4ab221d6 100644
--- a/pro/email/utils.go
+++ b/pro/email/utils.go
@@ -4,27 +4,20 @@ import "strings"
// mail related images hosted on github
var (
- nLogoTeal = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/N_Teal.png"
netmakerLogoTeal = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/netmaker-logo-2.png"
- netmakerMeshLogo = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/netmaker-mesh.png"
- linkedinIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/linkedin2x.png"
- discordIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/discord-logo-png-7617.png"
- githubIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/Octocat.png"
- mailIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/icons8-mail-24.png"
- addressIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/icons8-address-16.png"
- linkIcon = "https://raw.githubusercontent.com/gravitl/netmaker/netmaker_logos/img/logos/icons8-hyperlink-64.png"
)
type EmailBodyBuilder interface {
WithHeadline(text string) EmailBodyBuilder
WithParagraph(text string) EmailBodyBuilder
+ WithHtml(text string) EmailBodyBuilder
WithSignature() EmailBodyBuilder
Build() string
}
type EmailBodyBuilderWithH1HeadlineAndImage struct {
headline string
- paragraphs []string
+ bodyContent []string
hasSignature bool
}
@@ -34,7 +27,12 @@ func (b *EmailBodyBuilderWithH1HeadlineAndImage) WithHeadline(text string) Email
}
func (b *EmailBodyBuilderWithH1HeadlineAndImage) WithParagraph(text string) EmailBodyBuilder {
- b.paragraphs = append(b.paragraphs, text)
+ b.bodyContent = append(b.bodyContent, styledParagraph(text))
+ return b
+}
+
+func (b *EmailBodyBuilderWithH1HeadlineAndImage) WithHtml(text string) EmailBodyBuilder {
+ b.bodyContent = append(b.bodyContent, text)
return b
}
@@ -44,524 +42,134 @@ func (b *EmailBodyBuilderWithH1HeadlineAndImage) WithSignature() EmailBodyBuilde
}
func (b *EmailBodyBuilderWithH1HeadlineAndImage) Build() string {
- // map paragraphs to styled paragraphs
- styledParagraphsSlice := make([]string, len(b.paragraphs))
- for i, paragraph := range b.paragraphs {
- styledParagraphsSlice[i] = styledParagraph(paragraph)
- }
- // join styled paragraphs
- styledParagraphsString := strings.Join(styledParagraphsSlice, "")
+ bodyContent := strings.Join(b.bodyContent, "")
- signature := ""
- if b.hasSignature {
- signature = styledSignature()
- }
+ // TODO: Edit design to add signature.
+ //signature := ""
+ //if b.hasSignature {
+ // signature = styledSignature()
+ //}
return `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ` + b.headline + `
- |
-
-
- |
-
-
- |
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ` + styledParagraphsString + `
-
-
-
- |
-
-
- |
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Get In Touch With Us
-
-
-
- |
-
-
-
- |
-
-
-
- |
-
-
-
-
- |
-
-
-
-
-
- ` + signature + `
- `
+
+
+
+
+
+ Simple Transactional Email
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ ` + bodyContent + `
+ |
+
+
+
+
+
+
+ |
+ |
+
+
+
+`
}
func styledParagraph(text string) string {
- return `
- ` + text + `
-
`
-}
-
-func GetMailSignature() string {
- return styledSignature()
+ return `` + text + `
`
}