From 5c3c52b1fc8b0bd52d4744614ad4d2b8e2e03937 Mon Sep 17 00:00:00 2001 From: Pierre Lehnen <55164754+pierre-lehnen-rc@users.noreply.github.com> Date: Wed, 7 Jan 2026 21:25:05 -0300 Subject: [PATCH] feat: hide unconfirmed uploads from room's file list (#38077) --- .changeset/ninety-pans-search.md | 6 ++++++ apps/meteor/app/api/server/v1/channels.ts | 3 ++- apps/meteor/app/api/server/v1/groups.ts | 3 ++- apps/meteor/app/api/server/v1/im.ts | 3 ++- .../room/contextualBar/RoomFiles/hooks/useFilesList.ts | 1 + .../src/v1/channels/ChannelsFilesListProps.ts | 4 ++++ packages/rest-typings/src/v1/dm/DmFileProps.ts | 10 +++++++++- .../rest-typings/src/v1/groups/GroupsFilesProps.ts | 4 ++++ 8 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .changeset/ninety-pans-search.md diff --git a/.changeset/ninety-pans-search.md b/.changeset/ninety-pans-search.md new file mode 100644 index 0000000000000..555010b66f29b --- /dev/null +++ b/.changeset/ninety-pans-search.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': minor +'@rocket.chat/meteor': minor +--- + +Changes list of Room Files to only show files that have been successfully attached to a message diff --git a/apps/meteor/app/api/server/v1/channels.ts b/apps/meteor/app/api/server/v1/channels.ts index b5574e239ee4b..578a741efd52f 100644 --- a/apps/meteor/app/api/server/v1/channels.ts +++ b/apps/meteor/app/api/server/v1/channels.ts @@ -807,7 +807,7 @@ API.v1.addRoute( { authRequired: true, validateParams: isChannelsFilesListProps }, { async get() { - const { typeGroup, name, roomId, roomName } = this.queryParams; + const { typeGroup, name, roomId, roomName, onlyConfirmed } = this.queryParams; const findResult = await findChannelByIdOrName({ params: { @@ -829,6 +829,7 @@ API.v1.addRoute( ...query, ...(name ? { name: { $regex: name || '', $options: 'i' } } : {}), ...(typeGroup ? { typeGroup } : {}), + ...(onlyConfirmed && { expiresAt: { $exists: false } }), }; const { cursor, totalCount } = await Uploads.findPaginatedWithoutThumbs(filter, { diff --git a/apps/meteor/app/api/server/v1/groups.ts b/apps/meteor/app/api/server/v1/groups.ts index 311e383232171..72ea8402d4c0c 100644 --- a/apps/meteor/app/api/server/v1/groups.ts +++ b/apps/meteor/app/api/server/v1/groups.ts @@ -392,7 +392,7 @@ API.v1.addRoute( { authRequired: true, validateParams: isGroupsFilesProps }, { async get() { - const { typeGroup, name, roomId, roomName } = this.queryParams; + const { typeGroup, name, roomId, roomName, onlyConfirmed } = this.queryParams; const findResult = await findPrivateGroupByIdOrName({ params: roomId ? { roomId } : { roomName }, @@ -408,6 +408,7 @@ API.v1.addRoute( rid: findResult.rid, ...(name ? { name: { $regex: name || '', $options: 'i' } } : {}), ...(typeGroup ? { typeGroup } : {}), + ...(onlyConfirmed && { expiresAt: { $exists: false } }), }; const { cursor, totalCount } = await Uploads.findPaginatedWithoutThumbs(filter, { diff --git a/apps/meteor/app/api/server/v1/im.ts b/apps/meteor/app/api/server/v1/im.ts index b7251e67b1829..2e13de8023259 100644 --- a/apps/meteor/app/api/server/v1/im.ts +++ b/apps/meteor/app/api/server/v1/im.ts @@ -279,7 +279,7 @@ API.v1.addRoute( }, { async get() { - const { typeGroup, name, roomId, username } = this.queryParams; + const { typeGroup, name, roomId, username, onlyConfirmed } = this.queryParams; const { offset, count } = await getPaginationItems(this.queryParams); const { sort, fields, query } = await this.parseJsonQuery(); @@ -296,6 +296,7 @@ API.v1.addRoute( rid: room._id, ...(name ? { name: { $regex: name || '', $options: 'i' } } : {}), ...(typeGroup ? { typeGroup } : {}), + ...(onlyConfirmed && { expiresAt: { $exists: false } }), }; const { cursor, totalCount } = Uploads.findPaginatedWithoutThumbs(filter, { diff --git a/apps/meteor/client/views/room/contextualBar/RoomFiles/hooks/useFilesList.ts b/apps/meteor/client/views/room/contextualBar/RoomFiles/hooks/useFilesList.ts index 35555709c6362..cd6e763064b5a 100644 --- a/apps/meteor/client/views/room/contextualBar/RoomFiles/hooks/useFilesList.ts +++ b/apps/meteor/client/views/room/contextualBar/RoomFiles/hooks/useFilesList.ts @@ -54,6 +54,7 @@ export const useFilesList = ( ...(options.type !== 'all' && { typeGroup: options.type, }), + onlyConfirmed: true, }); const items = files.map((file) => ({ diff --git a/packages/rest-typings/src/v1/channels/ChannelsFilesListProps.ts b/packages/rest-typings/src/v1/channels/ChannelsFilesListProps.ts index 20fb49885f6b2..903f7d0d0f022 100644 --- a/packages/rest-typings/src/v1/channels/ChannelsFilesListProps.ts +++ b/packages/rest-typings/src/v1/channels/ChannelsFilesListProps.ts @@ -11,6 +11,7 @@ export type ChannelsFilesListProps = PaginatedRequest< name?: string; typeGroup?: string; query?: string; + onlyConfirmed?: boolean; } >; @@ -49,6 +50,9 @@ const channelsFilesListPropsSchema = { type: 'string', nullable: true, }, + onlyConfirmed: { + type: 'boolean', + }, }, oneOf: [{ required: ['roomId'] }, { required: ['roomName'] }], required: [], diff --git a/packages/rest-typings/src/v1/dm/DmFileProps.ts b/packages/rest-typings/src/v1/dm/DmFileProps.ts index 019a3e30514bb..b68bfa1cd4651 100644 --- a/packages/rest-typings/src/v1/dm/DmFileProps.ts +++ b/packages/rest-typings/src/v1/dm/DmFileProps.ts @@ -5,7 +5,12 @@ import type { PaginatedRequest } from '../../helpers/PaginatedRequest'; const ajv = new Ajv({ coerceTypes: true }); export type DmFileProps = PaginatedRequest< - ({ roomId: string; username?: string } | { roomId?: string; username: string }) & { name?: string; typeGroup?: string; query?: string } + ({ roomId: string; username?: string } | { roomId?: string; username: string }) & { + name?: string; + typeGroup?: string; + query?: string; + onlyConfirmed?: boolean; + } >; const dmFilesListPropsSchema = { @@ -43,6 +48,9 @@ const dmFilesListPropsSchema = { type: 'string', nullable: true, }, + onlyConfirmed: { + type: 'boolean', + }, }, oneOf: [{ required: ['roomId'] }, { required: ['username'] }], required: [], diff --git a/packages/rest-typings/src/v1/groups/GroupsFilesProps.ts b/packages/rest-typings/src/v1/groups/GroupsFilesProps.ts index bfbd83d7388a7..e2b2e0d16d5c2 100644 --- a/packages/rest-typings/src/v1/groups/GroupsFilesProps.ts +++ b/packages/rest-typings/src/v1/groups/GroupsFilesProps.ts @@ -10,6 +10,7 @@ const ajv = new Ajv({ export type GroupsFilesProps = PaginatedRequest & { name?: string; typeGroup?: string; + onlyConfirmed?: boolean; }; const GroupsFilesPropsSchema = { @@ -47,6 +48,9 @@ const GroupsFilesPropsSchema = { type: 'string', nullable: true, }, + onlyConfirmed: { + type: 'boolean', + }, }, oneOf: [{ required: ['roomId'] }, { required: ['roomName'] }], required: [],