-
Notifications
You must be signed in to change notification settings - Fork 13k
fix: make email notifications support multiple files #38184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 32160cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughRefactors server email assembly to include multiple file attachments and mixed text, adds plural English i18n keys for multi-file messages, introduces optional Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UploadService as File Upload Service
participant Server
participant Email as Email Service
User->>UploadService: Upload file(s) + message
UploadService->>Server: parseFileIntoMessageAttachments(files) (adds typeGroup)
Server->>Server: persist IMessage with files[]
Server->>Server: build email content (header + contentParts for text + per-file entries)
Server->>Email: send composed email with attachments
Email-->>User: deliver notification (inbox)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #38184 +/- ##
===========================================
+ Coverage 70.62% 70.64% +0.01%
===========================================
Files 3136 3136
Lines 108626 108637 +11
Branches 19584 19576 -8
===========================================
+ Hits 76716 76744 +28
+ Misses 29898 29888 -10
+ Partials 2012 2005 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@apps/meteor/app/lib/server/functions/notifications/email.js`:
- Line 34: The hasText check currently treats undefined/null as text because it
uses message.msg !== ''; change the check to ensure message.msg is a non-empty
string (e.g., const hasText = typeof message.msg === 'string' &&
message.msg.trim() !== ''), and when passing into escapeHTML ensure you only
call it with a string (e.g., escapeHTML(message.msg || '') or guard by hasText)
so "undefined" is never rendered in the email body.
- Around line 79-89: The current block aligns files to attachments by index
which is fragile; change it to match each file to its metadata by name (e.g.,
for each file in files use message.attachments?.find(a => a.title === (file.name
|| '')) or similar) instead of using attachments[index]. Also add a defensive
fallback for missing file.name (use empty string or a safe fallback) and
continue to use escapeHTML for both the file name and the matched
attachment.description when building part; update references in this block
(files, message.attachments, escapeHTML) to use the name-based lookup pattern
used in sendTranscript.ts and OmnichannelTranscript.ts.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
.changeset/rotten-foxes-marry.mdapps/meteor/app/lib/server/functions/notifications/email.jspackages/i18n/src/locales/en.i18n.json
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/lib/server/functions/notifications/email.js
🧠 Learnings (3)
📓 Common learnings
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.
📚 Learning: 2025-11-19T12:32:29.696Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37547
File: packages/i18n/src/locales/en.i18n.json:634-634
Timestamp: 2025-11-19T12:32:29.696Z
Learning: Repo: RocketChat/Rocket.Chat
Context: i18n workflow
Learning: In this repository, new translation keys should be added to packages/i18n/src/locales/en.i18n.json only; other locale files are populated via the external translation pipeline and/or fall back to English. Do not request adding the same key to all locale files in future reviews.
Applied to files:
.changeset/rotten-foxes-marry.mdpackages/i18n/src/locales/en.i18n.json
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.
Applied to files:
.changeset/rotten-foxes-marry.mdpackages/i18n/src/locales/en.i18n.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (1/4)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (4/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (3/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (5/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (1/5)
- GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (2/5)
- GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (4/4)
🔇 Additional comments (6)
.changeset/rotten-foxes-marry.md (1)
1-6: LGTM! Well-formed changeset.The changeset correctly specifies patch-level bumps for both affected packages (
@rocket.chat/i18nfor translation key additions and@rocket.chat/meteorfor the email notification logic changes). The description accurately summarizes the fix.packages/i18n/src/locales/en.i18n.json (1)
5643-5644: Looks good; please double-checkcountinterpolation and plural key selection.These new plural keys are consistent with the existing singular variants and the repo’s approach (separate keys vs
{one/other}blocks). Also good that they’re only added toen.i18n.json(no need to touch other locales). Based on learnings, …Only ask: ensure the email notification code always:
- uses these keys only when
count > 1(socount=1doesn’t render “1 files”), and- passes the interpolation param as
count(not e.g.filesCount).apps/meteor/app/lib/server/functions/notifications/email.js (4)
37-55: LGTM!The header selection logic correctly handles all combinations of single/multiple files and group/direct chat scenarios. The
countparameter is properly passed for i18n pluralization support.
57-63: LGTM!The updated e2e check correctly allows file metadata to be displayed even for encrypted messages, while the early return for disabled
Email_notification_show_messageis appropriate.
65-77: LGTM!The text content processing correctly escapes HTML, processes message tokens, and converts newlines to
<br/>tags for email rendering.
91-93: LGTM!The content assembly correctly combines the header with all content parts, maintaining proper HTML formatting with
<br/>separators.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 3 files
|
@ricardogarim, conversation resolved as requested. |
Proposed changes (including videos or screenshots)
As per CORE-1629, this PR adds support for multiple file attachments in email notifications.
Previously, when a user received an offline email notification for a message containing multiple files, only the first file was shown. Now all files are listed in the notification email.
Issue(s)
Steps to test or reproduce
You can get docker-compose of the email local services on #38183.
1. Setup
2. Test Single File (baseline)
<UserA> sent you a filewith the file name3. Test Multiple Files (new feature)
<UserA> sent you X files(with correct count)4. Test in Channel (group chat)
<UserA> uploaded X files on <channel>Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.