diff --git a/.changeset/olive-dogs-jam.md b/.changeset/olive-dogs-jam.md new file mode 100644 index 0000000000000..4205feeed4021 --- /dev/null +++ b/.changeset/olive-dogs-jam.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': major +'@rocket.chat/meteor': major +--- + +Removes deprecated endpoint `channels.images`. Moving forward, use `rooms.images` endpoint. diff --git a/apps/meteor/app/api/server/v1/channels.ts b/apps/meteor/app/api/server/v1/channels.ts index b69487bdd22bb..f288053773661 100644 --- a/apps/meteor/app/api/server/v1/channels.ts +++ b/apps/meteor/app/api/server/v1/channels.ts @@ -1,5 +1,5 @@ import { Team, Room } from '@rocket.chat/core-services'; -import type { IRoom, ISubscription, IUser, RoomType, IUpload } from '@rocket.chat/core-typings'; +import type { IRoom, ISubscription, IUser, RoomType } from '@rocket.chat/core-typings'; import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models'; import { isChannelsAddAllProps, @@ -18,7 +18,6 @@ import { isChannelsConvertToTeamProps, isChannelsSetReadOnlyProps, isChannelsDeleteProps, - isRoomsImagesProps, } from '@rocket.chat/rest-typings'; import { Meteor } from 'meteor/meteor'; @@ -800,55 +799,6 @@ API.v1.addRoute( }, ); -API.v1.addRoute( - 'channels.images', - { - authRequired: true, - validateParams: isRoomsImagesProps, - deprecation: { - version: '7.0.0', - alternatives: ['rooms.images'], - }, - }, - { - async get() { - const room = await Rooms.findOneById>(this.queryParams.roomId, { - projection: { t: 1, teamId: 1, prid: 1 }, - }); - - if (!room || !(await canAccessRoomAsync(room, { _id: this.userId }))) { - return API.v1.unauthorized(); - } - - let initialImage: IUpload | null = null; - if (this.queryParams.startingFromId) { - initialImage = await Uploads.findOneById(this.queryParams.startingFromId); - } - - const { offset, count } = await getPaginationItems(this.queryParams); - - const { cursor, totalCount } = Uploads.findImagesByRoomId(room._id, initialImage?.uploadedAt, { - skip: offset, - limit: count, - }); - - const [files, total] = await Promise.all([cursor.toArray(), totalCount]); - - // If the initial image was not returned in the query, insert it as the first element of the list - if (initialImage && !files.find(({ _id }) => _id === (initialImage as IUpload)._id)) { - files.splice(0, 0, initialImage); - } - - return API.v1.success({ - files, - count, - offset, - total, - }); - }, - }, -); - API.v1.addRoute( 'channels.getIntegrations', { diff --git a/packages/rest-typings/src/v1/channels/channels.ts b/packages/rest-typings/src/v1/channels/channels.ts index 6bda71004c5db..04bda08bd186a 100644 --- a/packages/rest-typings/src/v1/channels/channels.ts +++ b/packages/rest-typings/src/v1/channels/channels.ts @@ -1,8 +1,7 @@ -import type { IUpload, IUploadWithUser, IMessage, IRoom, ITeam, IGetRoomRoles, IUser, IIntegration } from '@rocket.chat/core-typings'; +import type { IUploadWithUser, IMessage, IRoom, ITeam, IGetRoomRoles, IUser, IIntegration } from '@rocket.chat/core-typings'; import type { PaginatedRequest } from '../../helpers/PaginatedRequest'; import type { PaginatedResult } from '../../helpers/PaginatedResult'; -import type { RoomsImagesProps } from '../rooms'; import type { ChannelsAddAllProps } from './ChannelsAddAllProps'; import type { ChannelsArchiveProps } from './ChannelsArchiveProps'; import type { ChannelsConvertToTeamProps } from './ChannelsConvertToTeamProps'; @@ -39,11 +38,6 @@ export type ChannelsEndpoints = { files: IUploadWithUser[]; }>; }; - '/v1/channels.images': { - GET: (params: RoomsImagesProps) => PaginatedResult<{ - files: IUpload[]; - }>; - }; '/v1/channels.members': { GET: ( params: PaginatedRequest<