Skip to content

Conversation

@ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented Jan 26, 2026

Proposed changes (including videos or screenshots)

This PR updates the Smarsh integration to be compatible with the new multiple file attachment format introduced in the multi-file upload feature on #32703.

Issue(s)

Steps to test or reproduce

1. Set up email testing environment

Create a docker-compose.mail-test.yml file:

  version: '3.8'

  services:
    greenmail:
      image: greenmail/standalone:2.0.0
      container_name: greenmail-smarsh
      ports:
        - "3025:3025"   # SMTP
        - "3143:3143"   # IMAP
      networks:
        - mail-network

    roundcube:
      image: roundcube/roundcubemail
      container_name: roundcube-smarsh
      ports:
        - "8080:80"
      environment:
        - ROUNDCUBEMAIL_DEFAULT_HOST=greenmail
        - ROUNDCUBEMAIL_DEFAULT_PORT=3143
        - ROUNDCUBEMAIL_SMTP_SERVER=greenmail
        - ROUNDCUBEMAIL_SMTP_PORT=3025
      depends_on:
        - greenmail
      networks:
        - mail-network

  networks:
    mail-network:
      driver: bridge

Start the containers: docker-compose -f docker-compose.mail-test.yml up -d

2. Configure Smarsh in Rocket.Chat

  1. Go to Administration -> Settings -> Smarsh
  2. Enable Smarsh integration
  3. Configure:
    • Smarsh Email: smarsh@localhost
    • From Email: rocketchat@localhost
    • Interval: Every 30 seconds (for testing)

3. Test single file message (baseline)

  1. Create a new channel
  2. Upload one file to the channel
  3. Open Roundcube (http://localhost:8080), log in as smarsh@localhost / smarsh
  4. Verify the email was received with the file listed in the message body

4. Test multiple file attachments (new feature)

  1. In the same channel, upload multiple files at once (2-3 files)
  2. Open Roundcube and verify:
    • The email was received successfully
    • All uploaded files are listed in the message body
    • Format matches the original single-file format: filename.jpg (url), filename2.png (url)

Further comments

When a message contains both text (message.msg) and files, only the file information is included in the Smarsh export - the message text is not displayed. This is pre-existing behavior from the original implementation and should be addressed in a separate task.

Summary by CodeRabbit

  • Bug Fixes
    • Smarsh integration now supports multiple file attachments per message.

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 26, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 26, 2026

🦋 Changeset detected

Latest commit: f9b0265

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

This PR includes changesets to release 40 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground 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/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services 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/mock-providers Patch
@rocket.chat/ui-video-conf 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 26, 2026

Walkthrough

This PR updates the Smarsh integration backend to support multiple file attachments per message by introducing a helper function to process files and unifying the file attachment handling logic.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/chatty-insects-notice.md
Patch release entry documenting Smarsh integration fix for multiple file attachment support
Smarsh File Generation
apps/meteor/app/smarsh-connector/server/functions/generateEml.ts
Added _processMessageFiles() helper to process multi-file attachments; refactored message rendering to handle both single and multiple files uniformly; updated SmarshHistory database write to use $set and $setOnInsert operators

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • pierre-lehnen-rc
  • tassoevan

Poem

🐰 Files multiply, no worries here,
The helper function makes them clear,
Multiple attachments now take flight,
Smarsh integration shines so bright! 📎✨

🚥 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 PR title accurately describes the main change: updating Smarsh integration to support multiple file attachments, directly matching the primary objective.
Linked Issues check ✅ Passed The changes successfully address CORE-1632 requirements: updating Smarsh integration for multiple file format, ensuring all file entries export with filenames and URLs, and maintaining existing formatting.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue: helper function for file processing, unified file attachment handling, and MongoDB operator updates align with multi-file compatibility requirements.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/smarsh-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 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.78%. Comparing base (08b586d) to head (f9b0265).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38338      +/-   ##
===========================================
+ Coverage    70.74%   70.78%   +0.03%     
===========================================
  Files         3159     3159              
  Lines       109384   109384              
  Branches     19676    19666      -10     
===========================================
+ Hits         77383    77423      +40     
+ Misses       29963    29930      -33     
+ Partials      2038     2031       -7     
Flag Coverage Δ
e2e 60.35% <ø> (+0.07%) ⬆️
e2e-api 48.10% <ø> (+0.09%) ⬆️
unit 71.90% <ø> (-0.01%) ⬇️

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.

@ricardogarim ricardogarim added this to the 8.2.0 milestone Jan 26, 2026
@ricardogarim ricardogarim marked this pull request as ready for review January 26, 2026 11:51
@github-actions
Copy link
Contributor

📦 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/26 12:02 (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-38338
  • Baseline: develop
  • Timestamp: 2026-01-26 12:02:22 UTC
  • Historical data points: 30

Updated: Mon, 26 Jan 2026 12:02:22 GMT

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 2 files

const fileLinks =
attachments
?.filter((a): a is MessageAttachment & { title: string } => 'title' in a && a.title !== undefined)
.map((a) => `${a.title} (${_getLink({ title_link: 'title_link' in a ? a.title_link || '' : '' })})`) || [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map((a) => `${a.title} (${_getLink({ title_link: 'title_link' in a ? a.title_link || '' : '' })})`) || [];
.map((a) => `${a.title} (${_getLink({ title_link: a.title_link || '' })})`) || [];

:ape_think: was there a reason for the ternary?

if (rows.length !== 0) {
const result = start + rows.join('') + end;

await SmarshHistory.updateOne(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would u b so kind to move this to the model? :please: (or create a task for doing it later)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants