Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert rooms endpoints to TS #28448

Merged
merged 8 commits into from Mar 17, 2023
3 changes: 1 addition & 2 deletions apps/meteor/app/api/server/index.ts
Expand Up @@ -30,8 +30,7 @@ import './v1/permissions';
import './v1/presence';
import './v1/push';
import './v1/roles';
import './v1/rooms.js';
import './v1/rooms.ts';
import './v1/rooms';
import './v1/settings';
import './v1/stats';
import './v1/subscriptions';
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/api/server/lib/rooms.ts
@@ -1,4 +1,4 @@
import type { IRoom, ISubscription } from '@rocket.chat/core-typings';
import type { IRoom, ISubscription, RoomAdminFieldsType } from '@rocket.chat/core-typings';
import { Rooms } from '@rocket.chat/models';

import { hasPermissionAsync, hasAtLeastOnePermissionAsync } from '../../../authorization/server/functions/hasPermission';
Expand All @@ -14,7 +14,7 @@ export async function findAdminRooms({
uid: string;
filter: string;
types: string[];
pagination: { offset: number; count: number; sort: [string, number][] };
pagination: { offset: number; count: number; sort: Record<string, 1 | -1> };
}): Promise<{
rooms: IRoom[];
count: number;
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function findAdminRooms({
};
}

export async function findAdminRoom({ uid, rid }: { uid: string; rid: string }): Promise<unknown> {
export async function findAdminRoom({ uid, rid }: { uid: string; rid: string }): Promise<Pick<IRoom, RoomAdminFieldsType> | null> {
if (!(await hasPermissionAsync(uid, 'view-room-administration'))) {
throw new Error('error-not-authorized');
}
Expand Down Expand Up @@ -127,7 +127,7 @@ export async function findChannelAndPrivateAutocompleteWithPagination({
}: {
uid: string;
selector: { name: string };
pagination: { offset: number; count: number; sort: [string, number][] };
pagination: { offset: number; count: number; sort: Record<string, 1 | -1> };
}): Promise<{
items: IRoom[];
total: number;
Expand Down