Skip to content

feat: Send multiple files into a single message#32703

Open
abhipatel0211 wants to merge 337 commits intoRocketChat:developfrom
abhipatel0211:feat/multiple_files_in_one_msg
Open

feat: Send multiple files into a single message#32703
abhipatel0211 wants to merge 337 commits intoRocketChat:developfrom
abhipatel0211:feat/multiple_files_in_one_msg

Conversation

@abhipatel0211
Copy link
Contributor

@abhipatel0211 abhipatel0211 commented Jun 29, 2024

Proposed changes (including videos or screenshots)

This PR aims to introduce the ability to send multiple files into a single message. In order to keep the compatibility with old integrations we're introducing a new setting, in order to use it you'll need to enabled it first otherwise it will send one file per message

Note

It's not available for livechat rooms yet

image

Closes #35651
Closes #24776
Closes #25918
Closes RocketChat/feature-requests#31

Steps to test or reproduce

  1. Enable the setting FileUpload_EnableMultipleFilesPerMessage
  2. Go to a room.
  3. Upload multiple files.
  4. Check the files attached in the composer.
  5. Send the message and see the files rendered in a single message

Further comments

This implementation is an initial version of the multiple file sharing feature. While it is functional, some minor bugs remain, particularly with image file sharing, which will be addressed in future updates.

CORE-847


This pull request introduces the ability to send multiple files in a single message within the Rocket.Chat application. Key changes include:

  • File Upload Enhancements: The file upload functionality has been significantly refactored to support multiple files, including updates to the UploadsAPI interface with new methods for managing uploads and handling encrypted content. The Upload type definition now includes both file and URL properties.

  • New Components and Hooks: Several new components and hooks have been added to manage file uploads, such as MessageComposerFile, MessageComposerFileArea, and MessageComposerFileLoader, which provide UI elements for file management, preview, and error handling. The useFileUploadDropTarget hook has been introduced to streamline file upload handling.

  • Thread and Message Integration: The PR adds support for thread-specific uploads and integrates file upload capabilities into various components like MessageBox, AudioMessageRecorder, and VideoMessageRecorder. The confirmFiles function is introduced to handle file confirmation and sending, with error handling and cleanup processes.

  • Localization and API Updates: The English localization file has been updated with new messages related to upload failures and file count limitations. A new API endpoint for media editing has been added to the REST typings.

Overall, this pull request enhances the file upload experience by allowing multiple files to be sent in a single message, improving the user interface, and refining the underlying upload logic.

Summary by CodeRabbit

  • New Features

    • Upload and send multiple files in a single message (configurable, max 10)
    • Inline composer file attachments with per-file rename before sending
    • Warning modal to "send anyway" when some uploads fail
  • Improvements

    • Better end-to-end encrypted file upload handling
    • Streamlined UX: drag-and-drop drop-target uploads and inline file list (thread-aware)
    • New server setting to enable/disable multi-file-per-message

@abhipatel0211 abhipatel0211 requested review from a team as code owners June 29, 2024 14:35
@changeset-bot
Copy link

changeset-bot bot commented Jun 29, 2024

🦋 Changeset detected

Latest commit: cb9ebf9

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/model-typings Minor
@rocket.chat/core-typings Minor
@rocket.chat/models Minor
@rocket.chat/i18n Minor
@rocket.chat/meteor Minor
@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/omnichannel-services Patch
rocketchat-services Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/rest-typings Minor
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-contexts Major
@rocket.chat/ui-voip Major
@rocket.chat/web-ui-registration Major
@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
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/network-broker Patch
@rocket.chat/ui-video-conf Major

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

@rodrigok rodrigok marked this pull request as draft July 5, 2024 17:21
@nazabucciarelli
Copy link
Contributor

Testing locally I've noticed I'm able to upload multiple files even though FileUpload_EnableMultipleFilesPerMessage is false. Is this correct?

@KevLehman
Copy link
Member

Testing locally I've noticed I'm able to upload multiple files even though FileUpload_EnableMultipleFilesPerMessage is false. Is this correct?

It depends, if the uploads are on the same message with the setting disabled, then we have a problem.

If the uploads are on multiple messges, then that should be the current behavior RC has for uploading (when you select/drop many files)

@dougfabris
Copy link
Member

Testing locally I've noticed I'm able to upload multiple files even though FileUpload_EnableMultipleFilesPerMessage is false. Is this correct?

please check carefully if it was sent in a single or multiple messages, I'm positive that it's working fine

@nazabucciarelli
Copy link
Contributor

Testing locally I've noticed I'm able to upload multiple files even though FileUpload_EnableMultipleFilesPerMessage is false. Is this correct?

please check carefully if it was sent in a single or multiple messages, I'm positive that it's working fine

Then it's ok 👍

before(async () => {
const channelInfoResponse = await request.get(api('channels.info')).set(credentials).query({ roomName: 'general' }).expect(200);
generalRoomId = channelInfoResponse.body.channel._id;

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
generalRoomId = 'GENERAL';

generalRoomId = channelInfoResponse.body.channel._id;

const file1Response = await request
.post(api(`rooms.media/${generalRoomId}`))
Copy link
Member

Choose a reason for hiding this comment

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

I could not find the 'chat.sendMessage' implementation or tests related

Comment on lines +836 to +839
.expect(200)
.expect((res: Response) => {
expect(res.body).to.have.property('success', true);
});
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
.expect(200)
.expect((res: Response) => {
expect(res.body).to.have.property('success', true);
});
.expect(200);

Comment on lines +810 to +811
const data = JSON.parse(sendMessageResponse.body.message);
messageWithFiles = data.result;
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
const data = JSON.parse(sendMessageResponse.body.message);
messageWithFiles = data.result;
messageWithFiles = JSON.parse(sendMessageResponse.body.message).result;

tshow,
previewUrls,
isSlashCommandAllowed,
tmid,
Copy link
Member

Choose a reason for hiding this comment

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

there is no reason to pass tmid here chat/this contains tmid

Comment on lines +7 to +19
const customCSS = css`
animation: spin-animation 0.8s linear infinite;

@keyframes spin-animation {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}
`;
Copy link
Member

Choose a reason for hiding this comment

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

this can be defined outside the MessageComposerFileLoader component

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

Projects

None yet