fix: personalize the team invitation email#1747
Merged
Merged
Conversation
The invite email was maximally generic - 'You have been invited to join an organization', a bare 'click here' link, no org or inviter name - which is exactly the shape spam filters penalize. Name the inviter and the team in the subject and body and use a descriptive link text instead. Repro: an invitation sent to a Gmail test account landed in spam, even though earlier Postiz emails had reached its regular inbox. After this change the same invitation to the same account landed in the regular inbox. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Comment on lines
+89
to
+92
| : user.email; | ||
| await this._notificationsService.sendEmail( | ||
| body.email, | ||
| 'You have been invited to join an organization', | ||
| `You have been invited to join an organization. Click <a href="${url}">here</a> to join.<br />The link will expire in 2 days.` | ||
| `${user.name || user.email} invited you to join "${org.name}"`, |
There was a problem hiding this comment.
Bug: The organization name org.name is not escaped before being interpolated into an email's subject and HTML body, which can break email rendering.
Severity: MEDIUM
Suggested Fix
Apply HTML entity escaping to the org.name variable before it is used in the email subject and body. This will convert special characters (e.g., < to <) and ensure they are displayed as text rather than being interpreted as HTML by the email client.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
libraries/nestjs-libraries/src/database/prisma/organizations/organization.service.ts#L89-L92
Potential issue: The organization name, `org.name`, is used to construct an email
invitation in `organization.service.ts`. This name is then interpolated directly into
both the email subject and the HTML body without any sanitization or escaping. If an
organization's name contains special HTML characters such as `<`, `>`, or `&`, it can
break the HTML structure of the email. This could lead to incorrect rendering or display
issues in the recipient's email client, potentially making the invitation unreadable.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix (email deliverability).
Why was this change needed?
Team invitation emails were landing in Gmail spam. The email was maximally generic — subject "You have been invited to join an organization", a bare "click here" link, no org or inviter name — which is exactly the shape spam filters penalize.
The invite now names the inviter and the team in the subject and body, with a descriptive link text: subject becomes "Gilad invited you to join "Resisi"", body "Gilad (gilad@postiz.com) has invited you to join the "Resisi" team. Accept the invitation to get started." Only the email content changed; the invite link and flow are untouched.
Repro and verification: an invitation sent to a Gmail test account landed in spam, even though earlier Postiz emails had reached that inbox. After this change, the same invitation to the same account landed in the regular inbox.
Other information:
Independent of the open #1745/#1746 stack.
Checklist:
🤖 Generated with Claude Code