Skip to content
Snippets Groups Projects
Commit b167db0b authored by Abhinav Kumar's avatar Abhinav Kumar Committed by Guilherme Gazzo
Browse files

chore!: remove deprecated endpoint channels.images (#33471)

parent 3091566a
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/rest-typings': major
'@rocket.chat/meteor': major
---
Removes deprecated endpoint `channels.images`. Moving forward, use `rooms.images` endpoint.
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<Pick<IRoom, '_id' | 't' | 'teamId' | 'prid'>>(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',
{
......
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<
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment