Skip to content

Commit

Permalink
feat(go): update email template.
Browse files Browse the repository at this point in the history
  • Loading branch information
VishalDalwadi committed Oct 9, 2024
1 parent 3af1d59 commit 0bf9214
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
5 changes: 3 additions & 2 deletions pro/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
43 changes: 28 additions & 15 deletions pro/email/invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("<ol>").
WithHtml("<li>Accept Invite - Click the button to accept your invitation.</li>").
WithHtml("<br>").
WithHtml(fmt.Sprintf("<a style=\"background:#5E5DF0; border-radius:999px; box-shadow:#5E5DF0 0 10px 20px -10px; box-sizing:border-box; color:#FFFFFF !important; cursor:pointer; font-family:Helvetica; font-size:16px; font-weight:700; line-height:24px; opacity:1; outline:0 solid transparent; padding:8px 18px; user-select:none; -webkit-user-select:none; touch-action:manipulation; width:fit-content; word-break:break-word; border:0; margin:20px 20px 20px 0px; text-decoration:none;\" href=\"%s\">Accept Invite</a>", invite.InviteURL)).
WithHtml("<br><br>").
WithHtml(fmt.Sprintf("<li>Download the Remote Access Client (RAC). Visit our download page to get the RAC for your device: <a href=\"%s\">%s</a>.</li>", downloadLink, downloadLink)).
WithHtml(fmt.Sprintf("<li>Click to <a href=\"%s\">Accept Your Invitation</a> and setup your account.</li>", invite.InviteURL)).
WithHtml("<br>").
WithHtml("<li>Choose the appropriate version for your operating system.</li>").
WithHtml(fmt.Sprintf("<li><a href=\"%s\">Download the Remote Access Client (RAC)</a>.</li>", downloadLink))

if invite.PlatformRoleID == models.AdminRole.String() || invite.PlatformRoleID == models.PlatformUser.String() {
content = content.
WithHtml("<br>").
WithHtml(fmt.Sprintf("<li>Access the <a href=\"%s\">Netmaker Dashboard</a> - use it to manage your network settings and view network status.</li>", dashboardURL))
}

return content.
WithHtml("</ol>").
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: <a href=\"%s\">%s</a>.", racDocsLink, racDocsLink)).
WithParagraph(fmt.Sprintf("If you have any questions or need assistance, don't hesitate to contact our support team at <a href=\"mailto:%s\">%s</a>.", supportEmail, supportEmail)).
WithParagraph("Welcome aboard, and enjoy your secure connection!").
WithParagraph("Important Information:").
WithHtml("<ul>").
WithHtml(fmt.Sprintf("<li>Your Tenant ID: %s</li>", servercfg.GetNetmakerTenantID())).
WithHtml("</ul>").
WithParagraph(fmt.Sprintf("If you have any questions or need assistance, please contact our support team at <a href=\"mailto:%s\">%s</a>.", supportEmail, supportEmail)).
WithParagraph("Best regards,").
WithParagraph("The Netmaker Team").
Build()
Expand Down

0 comments on commit 0bf9214

Please sign in to comment.