diff --git a/internal/api/handler/organization.go b/internal/api/handler/organization.go index 0c734024..84ee2e59 100644 --- a/internal/api/handler/organization.go +++ b/internal/api/handler/organization.go @@ -9,6 +9,7 @@ import ( "github.com/warmbly/warmbly/internal/api/middleware" "github.com/warmbly/warmbly/internal/errx" "github.com/warmbly/warmbly/internal/models" + "github.com/warmbly/warmbly/internal/notify/templates" ) // CreateOrganization creates a new organization @@ -221,16 +222,11 @@ func (h *Handler) InviteMember(c *gin.Context) { // Send invitation email if h.EmailNotificationService != nil { subject := fmt.Sprintf("You've been invited to join %s on Warmbly", orgName) - body := fmt.Sprintf(` -

You've been invited!

-

%s has invited you to join %s on Warmbly.

-

Click the link below to accept the invitation:

-

Accept Invitation

-

This invitation expires in 7 days.

-

If you don't have an account yet, you'll be able to create one when you accept the invitation.

- `, inviterName, orgName, inv.Token) - - go h.EmailNotificationService.Send(c.Request.Context(), []string{req.Email}, nil, nil, subject, body) + acceptURL := fmt.Sprintf("%s/invite?token=%s", templates.AppURL, inv.Token) + // GenerateInvitationHTML reports its own render errors to Sentry. + if body, gerr := templates.GenerateInvitationHTML(inviterName, orgName, acceptURL); gerr == nil { + go h.EmailNotificationService.Send(c.Request.Context(), []string{req.Email}, nil, nil, subject, body) + } } c.JSON(http.StatusCreated, gin.H{