diff --git a/packages/emails/emails.go b/packages/emails/emails.go index cbc3110e2..0a3a8fe53 100644 --- a/packages/emails/emails.go +++ b/packages/emails/emails.go @@ -61,7 +61,7 @@ func DefaultPresenterConfig(baseURL string) PresenterConfig { BaseURL: baseURL, SenderCompanyName: "Probo", SenderCompanyWebsiteURL: "https://www.getprobo.com", - SenderCompanyLogoURL: baseurl.MustParse(baseURL).WithPath("/logos/probo.png").MustString(), + SenderCompanyLogoURL: baseurl.MustParse(baseURL).AppendPath("/logos/probo.png").MustString(), SenderCompanyHeadquarterAddress: "Probo Inc, 490 Post St, STE 640, San Francisco, CA, 94102, US", } } @@ -123,7 +123,7 @@ var ( func (p *Presenter) RenderConfirmEmail(confirmationURLPath string, confirmationTokenParam string) (subject string, textBody string, htmlBody *string, err error) { confirmationUrl := baseurl. MustParse(p.variables.BaseURL). - WithPath(confirmationURLPath). + AppendPath(confirmationURLPath). WithQuery("token", confirmationTokenParam). MustString() @@ -142,7 +142,7 @@ func (p *Presenter) RenderConfirmEmail(confirmationURLPath string, confirmationT func (p *Presenter) RenderPasswordReset(resetPasswordURLPath string, resetPasswordToken string) (subject string, textBody string, htmlBody *string, err error) { resetUrl := baseurl. MustParse(p.variables.BaseURL). - WithPath(resetPasswordURLPath). + AppendPath(resetPasswordURLPath). WithQuery("token", resetPasswordToken). MustString() @@ -161,7 +161,7 @@ func (p *Presenter) RenderPasswordReset(resetPasswordURLPath string, resetPasswo func (p *Presenter) RenderInvitation(invitationURLPath string, invitationToken string, organizationName string) (subject string, textBody string, htmlBody *string, err error) { invitationURL := baseurl. MustParse(p.variables.BaseURL). - WithPath(invitationURLPath). + AppendPath(invitationURLPath). WithQuery("token", invitationToken). WithQuery("fullName", p.variables.RecipientFullName). MustString() @@ -182,7 +182,7 @@ func (p *Presenter) RenderInvitation(invitationURLPath string, invitationToken s func (p *Presenter) RenderDocumentSigning(signinURLPath string, token string, organizationName string) (subject string, textBody string, htmlBody *string, err error) { signingURL := baseurl.MustParse(p.variables.BaseURL). - WithPath(signinURLPath). + AppendPath(signinURLPath). WithQuery("token", token). MustString() @@ -265,7 +265,7 @@ func (p *Presenter) RenderMagicLink(magicLinkUrlPath string, tokenString string, OrganizationName string }{ PresenterVariables: p.variables, - MagicLinkURL: baseurl.MustParse(p.variables.BaseURL).WithPath(magicLinkUrlPath).WithQuery("token", tokenString).MustString(), + MagicLinkURL: baseurl.MustParse(p.variables.BaseURL).AppendPath(magicLinkUrlPath).WithQuery("token", tokenString).MustString(), DurationInMinutes: int(tokenDuration.Minutes()), OrganizationName: organizationName, } diff --git a/packages/emails/src/TrustCenterAccess.tsx b/packages/emails/src/TrustCenterAccess.tsx index 09d65fe90..209c6e1ac 100644 --- a/packages/emails/src/TrustCenterAccess.tsx +++ b/packages/emails/src/TrustCenterAccess.tsx @@ -19,7 +19,7 @@ export const TrustCenterAccess = () => {
-
diff --git a/packages/emails/templates/trust-center-access.txt b/packages/emails/templates/trust-center-access.txt index e459d457e..e6d2cbf18 100644 --- a/packages/emails/templates/trust-center-access.txt +++ b/packages/emails/templates/trust-center-access.txt @@ -4,6 +4,6 @@ Hi {{.RecipientFullName}}, You have been granted access to {{.OrganizationName}}'s compliance page! Click the link below to access it: -{{.AccessUrl}} +{{.BaseURL}} Probo Inc, 490 Post St, STE 640, San Francisco, CA, 94102, US diff --git a/pkg/baseurl/baseurl.go b/pkg/baseurl/baseurl.go index 9417ea91c..ae6b2ea4f 100644 --- a/pkg/baseurl/baseurl.go +++ b/pkg/baseurl/baseurl.go @@ -137,6 +137,32 @@ func (b *BaseURL) WithPath(path string) *URLBuilder { } } +// WithPath returns a URLBuilder with the specified path. +// The path will be properly joined with the base URL's path. +func (b *BaseURL) AppendPath(path string) *URLBuilder { + if b == nil { + return &URLBuilder{err: fmt.Errorf("base URL is nil")} + } + + basePath := strings.TrimSuffix(b.parsed.Path, "/") + + // Ensure path starts with / + if !strings.HasPrefix(path, "/") { + path = "/" + path + } + + path = basePath + path + + // Ensure path does not end with / + path = strings.TrimSuffix(path, "/") + + return &URLBuilder{ + base: b, + path: path, + query: make(url.Values), + } +} + // WithQuery adds a query parameter to the URL. func (ub *URLBuilder) WithQuery(key, value string) *URLBuilder { if ub.err != nil { diff --git a/pkg/trust/trust_center_access_service.go b/pkg/trust/trust_center_access_service.go index 66cface30..ad9ac2007 100644 --- a/pkg/trust/trust_center_access_service.go +++ b/pkg/trust/trust_center_access_service.go @@ -602,7 +602,11 @@ func (s *TrustCenterAccessService) sendDocumentAccessRejectedEmail( return fmt.Errorf("cannot get compliance page email presenter config: %w", err) } - emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, access.Name) + fullName := access.Name + if fullName == "" { + fullName = access.Email.Username() + } + emailPresenter := emails.NewPresenterFromConfig(emailPresenterCfg, fullName) subject, textBody, htmlBody, err := emailPresenter.RenderTrustCenterDocumentAccessRejected( fileNames,