Skip to content

Commit 5c3c52b

Browse files
feat: hide unconfirmed uploads from room's file list (RocketChat#38077)
1 parent a1dee4e commit 5c3c52b

8 files changed

Lines changed: 30 additions & 4 deletions

File tree

.changeset/ninety-pans-search.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@rocket.chat/rest-typings': minor
3+
'@rocket.chat/meteor': minor
4+
---
5+
6+
Changes list of Room Files to only show files that have been successfully attached to a message

apps/meteor/app/api/server/v1/channels.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ API.v1.addRoute(
807807
{ authRequired: true, validateParams: isChannelsFilesListProps },
808808
{
809809
async get() {
810-
const { typeGroup, name, roomId, roomName } = this.queryParams;
810+
const { typeGroup, name, roomId, roomName, onlyConfirmed } = this.queryParams;
811811

812812
const findResult = await findChannelByIdOrName({
813813
params: {
@@ -829,6 +829,7 @@ API.v1.addRoute(
829829
...query,
830830
...(name ? { name: { $regex: name || '', $options: 'i' } } : {}),
831831
...(typeGroup ? { typeGroup } : {}),
832+
...(onlyConfirmed && { expiresAt: { $exists: false } }),
832833
};
833834

834835
const { cursor, totalCount } = await Uploads.findPaginatedWithoutThumbs(filter, {

apps/meteor/app/api/server/v1/groups.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ API.v1.addRoute(
392392
{ authRequired: true, validateParams: isGroupsFilesProps },
393393
{
394394
async get() {
395-
const { typeGroup, name, roomId, roomName } = this.queryParams;
395+
const { typeGroup, name, roomId, roomName, onlyConfirmed } = this.queryParams;
396396

397397
const findResult = await findPrivateGroupByIdOrName({
398398
params: roomId ? { roomId } : { roomName },
@@ -408,6 +408,7 @@ API.v1.addRoute(
408408
rid: findResult.rid,
409409
...(name ? { name: { $regex: name || '', $options: 'i' } } : {}),
410410
...(typeGroup ? { typeGroup } : {}),
411+
...(onlyConfirmed && { expiresAt: { $exists: false } }),
411412
};
412413

413414
const { cursor, totalCount } = await Uploads.findPaginatedWithoutThumbs(filter, {

apps/meteor/app/api/server/v1/im.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ API.v1.addRoute(
279279
},
280280
{
281281
async get() {
282-
const { typeGroup, name, roomId, username } = this.queryParams;
282+
const { typeGroup, name, roomId, username, onlyConfirmed } = this.queryParams;
283283

284284
const { offset, count } = await getPaginationItems(this.queryParams);
285285
const { sort, fields, query } = await this.parseJsonQuery();
@@ -296,6 +296,7 @@ API.v1.addRoute(
296296
rid: room._id,
297297
...(name ? { name: { $regex: name || '', $options: 'i' } } : {}),
298298
...(typeGroup ? { typeGroup } : {}),
299+
...(onlyConfirmed && { expiresAt: { $exists: false } }),
299300
};
300301

301302
const { cursor, totalCount } = Uploads.findPaginatedWithoutThumbs(filter, {

apps/meteor/client/views/room/contextualBar/RoomFiles/hooks/useFilesList.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const useFilesList = (
5454
...(options.type !== 'all' && {
5555
typeGroup: options.type,
5656
}),
57+
onlyConfirmed: true,
5758
});
5859

5960
const items = files.map((file) => ({

packages/rest-typings/src/v1/channels/ChannelsFilesListProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type ChannelsFilesListProps = PaginatedRequest<
1111
name?: string;
1212
typeGroup?: string;
1313
query?: string;
14+
onlyConfirmed?: boolean;
1415
}
1516
>;
1617

@@ -49,6 +50,9 @@ const channelsFilesListPropsSchema = {
4950
type: 'string',
5051
nullable: true,
5152
},
53+
onlyConfirmed: {
54+
type: 'boolean',
55+
},
5256
},
5357
oneOf: [{ required: ['roomId'] }, { required: ['roomName'] }],
5458
required: [],

packages/rest-typings/src/v1/dm/DmFileProps.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import type { PaginatedRequest } from '../../helpers/PaginatedRequest';
55
const ajv = new Ajv({ coerceTypes: true });
66

77
export type DmFileProps = PaginatedRequest<
8-
({ roomId: string; username?: string } | { roomId?: string; username: string }) & { name?: string; typeGroup?: string; query?: string }
8+
({ roomId: string; username?: string } | { roomId?: string; username: string }) & {
9+
name?: string;
10+
typeGroup?: string;
11+
query?: string;
12+
onlyConfirmed?: boolean;
13+
}
914
>;
1015

1116
const dmFilesListPropsSchema = {
@@ -43,6 +48,9 @@ const dmFilesListPropsSchema = {
4348
type: 'string',
4449
nullable: true,
4550
},
51+
onlyConfirmed: {
52+
type: 'boolean',
53+
},
4654
},
4755
oneOf: [{ required: ['roomId'] }, { required: ['username'] }],
4856
required: [],

packages/rest-typings/src/v1/groups/GroupsFilesProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ajv = new Ajv({
1010
export type GroupsFilesProps = PaginatedRequest<GroupsBaseProps> & {
1111
name?: string;
1212
typeGroup?: string;
13+
onlyConfirmed?: boolean;
1314
};
1415

1516
const GroupsFilesPropsSchema = {
@@ -47,6 +48,9 @@ const GroupsFilesPropsSchema = {
4748
type: 'string',
4849
nullable: true,
4950
},
51+
onlyConfirmed: {
52+
type: 'boolean',
53+
},
5054
},
5155
oneOf: [{ required: ['roomId'] }, { required: ['roomName'] }],
5256
required: [],

0 commit comments

Comments
 (0)