From 45c0e0630cd4ad63700b388a19caf4f866affff9 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 7 Mar 2022 13:48:33 -0300 Subject: [PATCH] Chore: Migrate REST API - getRoomCounters to Typescript (#3842) * Chore: Migrate REST API - getRoomCounters to Typescript * minor tweak --- app/definitions/rest/v1/channels.ts | 11 +++++++++++ app/definitions/rest/v1/groups.ts | 11 +++++++++++ app/lib/rocketchat/services/restApi.ts | 7 ++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/definitions/rest/v1/channels.ts b/app/definitions/rest/v1/channels.ts index 88ae895c..839067cf 100644 --- a/app/definitions/rest/v1/channels.ts +++ b/app/definitions/rest/v1/channels.ts @@ -52,6 +52,17 @@ export type ChannelsEndpoints = { 'channels.convertToTeam': { POST: (params: { channelId: string; channelName: string }) => { team: ITeam }; }; + 'channels.counters': { + GET: (params: { roomId: string }) => { + joined: boolean; + members: number; + unreads: number; + unreadsFrom: Date; + msgs: number; + latest: Date; + userMentions: number; + }; + }; 'channels.join': { POST: (params: { roomId: string; joinCode: string | null }) => { channel: IServerRoomItem }; }; diff --git a/app/definitions/rest/v1/groups.ts b/app/definitions/rest/v1/groups.ts index 80de882a..68c60955 100644 --- a/app/definitions/rest/v1/groups.ts +++ b/app/definitions/rest/v1/groups.ts @@ -46,6 +46,17 @@ export type GroupsEndpoints = { 'groups.convertToTeam': { POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; }; + 'groups.counters': { + GET: (params: { roomId: string }) => { + joined: boolean; + members: number; + unreads: number; + unreadsFrom: Date; + msgs: number; + latest: Date; + userMentions: number; + }; + }; 'groups.close': { POST: (params: { roomId: string }) => {}; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index e231c5e5..0175a9d1 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -278,10 +278,11 @@ export const toggleRead = (read: boolean, roomId: string) => { return sdk.post('subscriptions.read', { rid: roomId }); }; -export const getRoomCounters = (roomId: string, t: RoomTypes): any => +export const getRoomCounters = ( + roomId: string, + t: SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL +) => // RC 0.65.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get(`${roomTypeToApiType(t)}.counters`, { roomId }); export const getChannelInfo = (roomId: string): any =>