From 3af1d590eb080f0081ace89356d804dca7404ce9 Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Fri, 4 Oct 2024 16:47:44 +0530 Subject: [PATCH 1/7] feat(go): update email template. --- pro/email/invite.go | 65 ++--- pro/email/utils.go | 650 +++++++++----------------------------------- 2 files changed, 150 insertions(+), 565 deletions(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index 86018462c..70a0b4b08 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -13,54 +13,31 @@ type UserInvitedMail struct { // GetSubject - gets the subject of the email func (UserInvitedMail) GetSubject(info Notification) string { - return "You're invited to join Netmaker" + return "Access Your Secure Network with Netmaker" } // GetBody - gets the body of the email func (invite UserInvitedMail) GetBody(info Notification) string { - 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("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() - } - + downloadLink := "https://www.netmaker.io/download" + racDocsLink := "https://docs.v2.netmaker.io/guide/netmaker-professional/netmaker-remote-access-client-rac" + supportEmail := "support@netmaker.io" 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("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"). + 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("
  1. Accept Invite - Click the button to accept your invitation.
  2. "). + WithHtml("
    "). + WithHtml(fmt.Sprintf("Accept Invite", invite.InviteURL)). + WithHtml("

    "). + WithHtml(fmt.Sprintf("
  3. Download the Remote Access Client (RAC). Visit our download page to get the RAC for your device: %s.
  4. ", downloadLink, downloadLink)). + WithHtml("
    "). + WithHtml("
  5. Choose the appropriate version for your operating system.
  6. "). + WithHtml("
"). + WithParagraph(fmt.Sprintf("Important: Your Tenant ID is %s. You may need this for troubleshooting or support requests.", servercfg.GetNetmakerTenantID())). + WithParagraph(fmt.Sprintf("For detailed setup instructions and troubleshooting, please visit our RAC user guide: %s.", racDocsLink, racDocsLink)). + WithParagraph(fmt.Sprintf("If you have any questions or need assistance, don't hesitate to contact our support team at %s.", supportEmail, supportEmail)). + WithParagraph("Welcome aboard, and enjoy your secure connection!"). + WithParagraph("Best regards,"). + WithParagraph("The Netmaker Team"). Build() } diff --git a/pro/email/utils.go b/pro/email/utils.go index b689a8beb..4ab221d6a 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 ` - - - - - - - - - - - - - - - - - - - - ` + signature + ` - ` + + + + + + Simple Transactional Email + + + + + + + + + + + +` +} + +func styledParagraph(text string) string { + return `

` + text + `

` } From 0bf921429ab99e9df95a35dd7214ce5c3bcb8d1f Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Wed, 9 Oct 2024 12:10:35 +0530 Subject: [PATCH 2/7] feat(go): update email template. --- pro/controllers/users.go | 5 +++-- pro/email/invite.go | 43 ++++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/pro/controllers/users.go b/pro/controllers/users.go index c8119b79e..2915c8f9e 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 70a0b4b08..ecb57b68f 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -2,41 +2,54 @@ 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 "Access Your Secure Network with 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" - racDocsLink := "https://docs.v2.netmaker.io/guide/netmaker-professional/netmaker-remote-access-client-rac" supportEmail := "support@netmaker.io" - return invite.BodyBuilder. + + dashboardURL := fmt.Sprintf("https://dashboard.%s", servercfg.GetNmBaseDomain()) + if servercfg.DeployedByOperator() { + dashboardURL = fmt.Sprintf("%s/dashboard?tenant_id=%s", proLogic.GetAccountsUIHost(), servercfg.GetNetmakerTenantID()) + } + + 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("
  1. Accept Invite - Click the button to accept your invitation.
  2. "). - WithHtml("
    "). - WithHtml(fmt.Sprintf("Accept Invite", invite.InviteURL)). - WithHtml("

    "). - WithHtml(fmt.Sprintf("
  3. Download the Remote Access Client (RAC). Visit our download page to get the RAC for your device: %s.
  4. ", downloadLink, downloadLink)). + WithHtml(fmt.Sprintf("
  5. Click to Accept Your Invitation and setup your account.
  6. ", invite.InviteURL)). WithHtml("
    "). - WithHtml("
  7. Choose the appropriate version for your operating system.
  8. "). + WithHtml(fmt.Sprintf("
  9. Download the Remote Access Client (RAC).
  10. ", downloadLink)) + + if invite.PlatformRoleID == models.AdminRole.String() || invite.PlatformRoleID == models.PlatformUser.String() { + content = content. + WithHtml("
    "). + WithHtml(fmt.Sprintf("
  11. Access the Netmaker Dashboard - use it to manage your network settings and view network status.
  12. ", dashboardURL)) + } + + return content. WithHtml("
"). - WithParagraph(fmt.Sprintf("Important: Your Tenant ID is %s. You may need this for troubleshooting or support requests.", servercfg.GetNetmakerTenantID())). - WithParagraph(fmt.Sprintf("For detailed setup instructions and troubleshooting, please visit our RAC user guide: %s.", racDocsLink, racDocsLink)). - WithParagraph(fmt.Sprintf("If you have any questions or need assistance, don't hesitate to contact our support team at %s.", supportEmail, supportEmail)). - WithParagraph("Welcome aboard, and enjoy your secure connection!"). + WithParagraph("Important Information:"). + 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() From a3ce2da02568d2146b431e2c1881ecdb6ed5318c Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Thu, 17 Oct 2024 16:21:04 +0530 Subject: [PATCH 3/7] feat(go): update email template. --- pro/email/invite.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index ecb57b68f..1fae1bd49 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -43,11 +43,20 @@ func (invite UserInvitedMail) GetBody(info Notification) string { WithHtml(fmt.Sprintf("
  • Access the Netmaker Dashboard - use it to manage your network settings and view network status.
  • ", dashboardURL)) } - return content. + content = content. WithHtml(""). WithParagraph("Important Information:"). - WithHtml("
      "). - WithHtml(fmt.Sprintf("
    • Your Tenant ID: %s
    • ", servercfg.GetNetmakerTenantID())). + WithHtml("
        ") + + if servercfg.DeployedByOperator() { + content = content. + WithHtml(fmt.Sprintf("
      • Your Tenant ID: %s
      • ", servercfg.GetNetmakerTenantID())) + } else { + content = content. + WithHtml(fmt.Sprintf("
      • Your Netmaker Domain: %s
      • ", servercfg.GetFrontendURL())) + } + + return content. WithHtml("
      "). WithParagraph(fmt.Sprintf("If you have any questions or need assistance, please contact our support team at %s.", supportEmail, supportEmail)). WithParagraph("Best regards,"). From 8be87ac6a472201b3aa7872b9ad3919431b86f54 Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Thu, 17 Oct 2024 16:29:41 +0530 Subject: [PATCH 4/7] feat(go): update email template. --- pro/email/invite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index 1fae1bd49..a34a2010e 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -53,7 +53,7 @@ func (invite UserInvitedMail) GetBody(info Notification) string { WithHtml(fmt.Sprintf("
    • Your Tenant ID: %s
    • ", servercfg.GetNetmakerTenantID())) } else { content = content. - WithHtml(fmt.Sprintf("
    • Your Netmaker Domain: %s
    • ", servercfg.GetFrontendURL())) + WithHtml(fmt.Sprintf("
    • Your Netmaker Domain: %s
    • ", fmt.Sprintf("api.%s", servercfg.GetNmBaseDomain()))) } return content. From 1831b669e50ccc29da2b3d7342bd0bfcfb932f90 Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Thu, 17 Oct 2024 16:36:50 +0530 Subject: [PATCH 5/7] feat(go): update email template. --- pro/email/invite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index a34a2010e..09d4ec714 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -59,7 +59,7 @@ func (invite UserInvitedMail) GetBody(info Notification) string { return content. 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("Best Regards,"). WithParagraph("The Netmaker Team"). Build() } From ca228bcab681be77f168a2c65eb0ab6997f737a5 Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Thu, 17 Oct 2024 17:48:19 +0530 Subject: [PATCH 6/7] feat(go): update email template. --- pro/email/invite.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index 09d4ec714..cf5be85db 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -43,20 +43,16 @@ func (invite UserInvitedMail) GetBody(info Notification) string { WithHtml(fmt.Sprintf("
  • Access the Netmaker Dashboard - use it to manage your network settings and view network status.
  • ", dashboardURL)) } - content = content. - WithHtml(""). - WithParagraph("Important Information:"). - WithHtml("
      ") - - if servercfg.DeployedByOperator() { - content = content. - WithHtml(fmt.Sprintf("
    • Your Tenant ID: %s
    • ", servercfg.GetNetmakerTenantID())) - } else { - content = content. - WithHtml(fmt.Sprintf("
    • Your Netmaker Domain: %s
    • ", fmt.Sprintf("api.%s", servercfg.GetNmBaseDomain()))) + 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,"). From 4150deb6b698a018afddc7d4a413d5104db36625 Mon Sep 17 00:00:00 2001 From: Vishal Dalwadi Date: Thu, 17 Oct 2024 18:53:05 +0530 Subject: [PATCH 7/7] feat(go): update email template. --- pro/email/invite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pro/email/invite.go b/pro/email/invite.go index cf5be85db..721b3387e 100644 --- a/pro/email/invite.go +++ b/pro/email/invite.go @@ -33,7 +33,7 @@ func (invite UserInvitedMail) GetBody(info Notification) string { 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("
      1. Click to Accept Your Invitation and setup your account.
      2. ", invite.InviteURL)). + WithHtml(fmt.Sprintf("
      3. Click here to accept your invitation and setup your account.
      4. ", invite.InviteURL)). WithHtml("
        "). WithHtml(fmt.Sprintf("
      5. Download the Remote Access Client (RAC).
      6. ", downloadLink))