Skip to content

Conversation

@abhinavkrin
Copy link
Member

@abhinavkrin abhinavkrin commented Apr 14, 2025

Proposed changes (including videos or screenshots)

When filesOnly is set to true, the current pruning logic removes all attachments—including quotes and other non file attachments This fix ensures only attachments of type file (e.g., images, documents, videos) are pruned while keeping non-file attachments intact.

This impacts:

  • Retention Policy cleanup under /admin/settings/RetentionPolicy
  • The rooms.cleanHistory endpoint

Issue(s)

Steps to test or reproduce

  1. Send a message with both file and quote attachments.
  2. Run retention cleanup or use the rooms.cleanHistory API with filesOnly: true.
  3. After cleanup, confirm:
    • File attachments are removed.
    • Quote and other non-file attachments remain.

Further comments

CORE-1051


This pull request addresses an issue in the Rocket.Chat repository where the cleanRoomHistory function, when invoked with filesOnly=true, was incorrectly removing all attachments, including quotes. The changes ensure that only file-type attachments are removed, preserving quotes and other non-file attachments.

Key changes include:

  1. Refactoring in cleanRoomHistory.ts: The method for handling file attachment removal has been optimized. Instead of updating each message individually, the process now collects all relevant message IDs and performs bulk database operations to remove attachments and clear file-related fields, improving performance.

  2. New Method in IMessagesModel.ts: A method has been added to remove file attachments by message IDs, with an optional replacement feature.

  3. Enhancements in Messages.ts: A new method is introduced to efficiently remove file attachments from messages using MongoDB aggregation operators, with an option to replace the attachments.

  4. Changeset Entries: Two changeset files have been added to document the patch affecting @rocket.chat/model-typings, @rocket.chat/models, and @rocket.chat/meteor.

These updates ensure that the room history pruning functionality works as intended, maintaining non-file attachments while removing only the specified file-type attachments.

@abhinavkrin abhinavkrin requested a review from a team as a code owner April 14, 2025 13:14
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 14, 2025

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

  • This PR is missing the required milestone or project

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 Apr 14, 2025

🦋 Changeset detected

Latest commit: e0f5256

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

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/meteor Patch
@rocket.chat/apps 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/stream-hub-service Patch
@rocket.chat/omnichannel-services Patch
rocketchat-services Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/presence Patch
@rocket.chat/network-broker Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration 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

@abhinavkrin abhinavkrin added this to the 7.6.0 milestone Apr 14, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Apr 14, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35797/

Built to branch gh-pages at 2025-05-15 20:42 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Apr 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.68%. Comparing base (0ff7a54) to head (e0f5256).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35797      +/-   ##
===========================================
- Coverage    64.70%   64.68%   -0.02%     
===========================================
  Files         3248     3248              
  Lines        95318    95318              
  Branches     17898    17858      -40     
===========================================
- Hits         61674    61661      -13     
- Misses       30740    30751      +11     
- Partials      2904     2906       +2     
Flag Coverage Δ
e2e 58.41% <ø> (+<0.01%) ⬆️
unit 71.87% <ø> (-0.03%) ⬇️

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.

@abhinavkrin abhinavkrin changed the title fix: cleanRoomHistory with filesOnly=true removed all attachments including quotes fix: cleanRoomHistory with filesOnly=true removes all attachments including quotes Apr 14, 2025
@abhinavkrin abhinavkrin marked this pull request as draft April 16, 2025 06:31
@scuciatto scuciatto removed this from the 7.6.0 milestone Apr 16, 2025
@abhinavkrin abhinavkrin force-pushed the fix/files-only-pruning-removes-all-attachments branch from 690eb31 to 0d9f23d Compare May 11, 2025 21:22
@kody-ai
Copy link

kody-ai bot commented May 11, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

Signed-off-by: Abhinav Kumar <[email protected]>
@kody-ai
Copy link

kody-ai bot commented May 11, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@abhinavkrin abhinavkrin marked this pull request as ready for review May 11, 2025 21:25
@abhinavkrin abhinavkrin requested a review from a team as a code owner May 11, 2025 21:25
Signed-off-by: Abhinav Kumar <[email protected]>
@kody-ai
Copy link

kody-ai bot commented May 11, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented May 13, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

1 similar comment
@kody-ai
Copy link

kody-ai bot commented May 13, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@abhinavkrin abhinavkrin force-pushed the fix/files-only-pruning-removes-all-attachments branch from 862f414 to 50a1714 Compare May 13, 2025 20:30
@kody-ai
Copy link

kody-ai bot commented May 13, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented May 14, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@cardoso cardoso added 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 labels May 15, 2025
@kodiakhq kodiakhq bot merged commit 6d36fc2 into develop May 16, 2025
50 checks passed
@kodiakhq kodiakhq bot deleted the fix/files-only-pruning-removes-all-attachments branch May 16, 2025 01:50
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