invite.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package email
  2. import (
  3. "fmt"
  4. "github.com/gravitl/netmaker/models"
  5. proLogic "github.com/gravitl/netmaker/pro/logic"
  6. "github.com/gravitl/netmaker/servercfg"
  7. )
  8. // UserInvitedMail - mail for users that are invited to a tenant
  9. type UserInvitedMail struct {
  10. BodyBuilder EmailBodyBuilder
  11. InviteURL string
  12. PlatformRoleID string
  13. }
  14. // GetSubject - gets the subject of the email
  15. func (UserInvitedMail) GetSubject(info Notification) string {
  16. return "Connect to Your Secure Network Using Netmaker"
  17. }
  18. // GetBody - gets the body of the email
  19. func (invite UserInvitedMail) GetBody(info Notification) string {
  20. downloadLink := "https://www.netmaker.io/download"
  21. supportEmail := "[email protected]"
  22. dashboardURL := fmt.Sprintf("https://dashboard.%s", servercfg.GetNmBaseDomain())
  23. if servercfg.DeployedByOperator() {
  24. dashboardURL = fmt.Sprintf("%s/dashboard?tenant_id=%s", proLogic.GetAccountsUIHost(), servercfg.GetNetmakerTenantID())
  25. }
  26. content := invite.BodyBuilder.
  27. WithParagraph("Hi,").
  28. WithParagraph("You've been invited to access a secure network via Netmaker Desktop App. Follow these simple steps to get connected:").
  29. WithHtml("<ol>").
  30. WithHtml(fmt.Sprintf("<li>Click <a href=\"%s\">here</a> to accept your invitation and setup your account.</li>", invite.InviteURL)).
  31. WithHtml("<br>").
  32. WithHtml(fmt.Sprintf("<li><a href=\"%s\">Download the Netmaker Desktop App</a>.</li>", downloadLink))
  33. if invite.PlatformRoleID == models.AdminRole.String() || invite.PlatformRoleID == models.PlatformUser.String() {
  34. content = content.
  35. WithHtml("<br>").
  36. 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))
  37. }
  38. connectionID := servercfg.GetNetmakerTenantID()
  39. if !servercfg.DeployedByOperator() {
  40. connectionID = fmt.Sprintf("api.%s", servercfg.GetNmBaseDomain())
  41. }
  42. return content.
  43. WithHtml("</ol>").
  44. WithParagraph("Important Information:").
  45. WithHtml("<ul>").
  46. WithHtml(fmt.Sprintf("<li>When connecting through RAC, please enter your server connection ID: %s.</li>", connectionID)).
  47. WithHtml("</ul>").
  48. 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)).
  49. WithParagraph("Best Regards,").
  50. WithParagraph("The Netmaker Team").
  51. Build()
  52. }