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

pull/33628/head
Abhinav Kumar 1 year ago committed by Guilherme Gazzo
parent 3091566a32
commit b167db0b37
  1. 6
      .changeset/olive-dogs-jam.md
  2. 52
      apps/meteor/app/api/server/v1/channels.ts
  3. 8
      packages/rest-typings/src/v1/channels/channels.ts

@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': major
'@rocket.chat/meteor': major
---
Removes deprecated endpoint `channels.images`. Moving forward, use `rooms.images` endpoint.

@ -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<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',
{

@ -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<

Loading…
Cancel
Save