Skip to content

Conversation

@ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented Jan 14, 2026

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

  1. Create two users: UserA (sender) and UserB (receiver)
  2. Configure UserB with:
    • A valid email address
    • Email notifications enabled (Preferences > Notifications > Email)
    • Set to receive email notifications for offline messages

2. Test Single File (baseline)

  1. Make sure UserB is offline (logged out or set to invisible)
  2. As UserA, send a message with 1 file attachment to UserB
  3. Check UserB's email inbox
  4. Verify the email shows: <UserA> sent you a file with the file name

3. Test Multiple Files (new feature)

  1. Make sure UserB is offline
  2. As UserA, send a message with multiple files (2-3 files) to UserB
  3. Check UserB's email inbox
  4. Verify:
    • Email header shows: <UserA> sent you X files (with correct count)
    • All file names are listed in the email body
    • File descriptions (if any) are shown for each file

4. Test in Channel (group chat)

  1. Add UserB to a channel
  2. Make sure UserB is offline
  3. As UserA, upload multiple files to the channel
  4. Check UserB's email inbox
  5. Verify:
    • Email header shows: <UserA> uploaded X files on <channel>
    • All file names are listed

Summary by CodeRabbit

  • Bug Fixes
    • Email notifications now list all attached files and show clearer headers for file-only, text-only, and mixed messages with correct context for direct messages and channels.
  • Localization
    • Added pluralized English messages so multi-file notifications show correct counts.
  • Chores
    • Updated release metadata to record dependency/version bumps.
  • Other
    • Attachment metadata improved to better identify and handle thumbnails in notifications.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 14, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

🦋 Changeset detected

Latest commit: 32160cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/i18n Patch
@rocket.chat/meteor Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-voip Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/queue-worker Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/model-typings Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/presence-service Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

Walkthrough

Refactors server email assembly to include multiple file attachments and mixed text, adds plural English i18n keys for multi-file messages, introduces optional typeGroup on FileProp and populates it in file-producing code, and adds a changeset bumping @rocket.chat/i18n and @rocket.chat/meteor.

Changes

Cohort / File(s) Summary
Changeset & Changelog
\.changeset/rotten-foxes-marry.md``
Declares patch bumps for @rocket.chat/i18n and @rocket.chat/meteor; records fix so email notifications list all files for messages with multiple attachments.
Email notification logic
apps/meteor/app/lib/server/functions/notifications/email.js
Reworked assembly to build headers and aggregate content parts (text + per-file entries); handles file-only, text-only, and mixed messages without early returns; preserves encrypted-preview, reply, deep-link, and attachment-fallback logic.
i18n (English)
packages/i18n/src/locales/en.i18n.json
Added plural keys User_uploaded_files_on_channel and User_uploaded_files_to_you to support multi-file messages.
File typing & producers
packages/core-typings/src/IMessage/MessageAttachment/Files/FileProp.ts, apps/meteor/app/file-upload/server/methods/sendFileMessage.ts
Added optional typeGroup?: string to FileProp and populated typeGroup on produced file and thumbnail entries returned by parseFileIntoMessageAttachments.

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)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • KevLehman

Poem

🐰 I hopped through code where files were stored,
I counted names and wrapped them toward,
Headers stitched and plurals sung,
Thumbnails tucked and threads unspun,
Inbox warmed — a tiny hop of joy.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: enabling email notifications to support multiple files instead of just the first one.
Linked Issues check ✅ Passed The PR fully addresses CORE-1629 requirements: detects/renders multiple files, updates header text with correct file counts via i18n entries, lists all file names with descriptions, and handles both direct and channel messages.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the email notification multiple-file support objective; no unrelated modifications detected beyond the stated requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/email-notifications-multi-file

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 14, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.64%. Comparing base (2b7dcc6) to head (32160cf).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 60.34% <ø> (+0.05%) ⬆️
e2e-api 48.05% <ø> (+0.07%) ⬆️
unit 71.68% <25.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "01/17 04:14 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38184
  • Baseline: develop
  • Timestamp: 2026-01-17 04:14:50 UTC
  • Historical data points: 30

Updated: Sat, 17 Jan 2026 04:14:51 GMT

@ricardogarim ricardogarim marked this pull request as ready for review January 14, 2026 16:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 28a8d39 and 7bce223.

📒 Files selected for processing (3)
  • .changeset/rotten-foxes-marry.md
  • apps/meteor/app/lib/server/functions/notifications/email.js
  • packages/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.md
  • packages/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.md
  • packages/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/i18n for translation key additions and @rocket.chat/meteor for 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-check count interpolation 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 to en.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 (so count=1 doesn’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 count parameter 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_message is 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.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

@ricardogarim, conversation resolved as requested.

KevLehman
KevLehman previously approved these changes Jan 14, 2026
@ricardogarim ricardogarim requested a review from a team as a code owner January 15, 2026 15:53
@ricardogarim ricardogarim added the stat: QA assured Means it has been tested and approved by a company insider label Jan 16, 2026
@ricardogarim ricardogarim added this to the 8.1.0 milestone Jan 16, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 16, 2026
@kodiakhq kodiakhq bot merged commit 9a20563 into develop Jan 17, 2026
45 checks passed
@kodiakhq kodiakhq bot deleted the fix/email-notifications-multi-file branch January 17, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants