Skip to content

Commit

Permalink
chore!: remove deprecated endpoint channels.images (#33471)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkrin authored and ggazzo committed Oct 17, 2024
1 parent 3091566 commit b167db0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 58 deletions.
6 changes: 6 additions & 0 deletions .changeset/olive-dogs-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': major
'@rocket.chat/meteor': major
---

Removes deprecated endpoint `channels.images`. Moving forward, use `rooms.images` endpoint.
52 changes: 1 addition & 51 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -18,7 +18,6 @@ import {
isChannelsConvertToTeamProps,
isChannelsSetReadOnlyProps,
isChannelsDeleteProps,
isRoomsImagesProps,
} from '@rocket.chat/rest-typings';
import { Meteor } from 'meteor/meteor';

Expand Down Expand Up @@ -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',
{
Expand Down
8 changes: 1 addition & 7 deletions packages/rest-typings/src/v1/channels/channels.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -39,11 +38,6 @@ export type ChannelsEndpoints = {
files: IUploadWithUser[];
}>;
};
'/v1/channels.images': {
GET: (params: RoomsImagesProps) => PaginatedResult<{
files: IUpload[];
}>;
};
'/v1/channels.members': {
GET: (
params: PaginatedRequest<
Expand Down

0 comments on commit b167db0

Please sign in to comment.