From 79f585a361ecbc01bdb10b40f8f13045cfe45a68 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 2 Mar 2022 16:40:27 -0300 Subject: [PATCH] Chore: Migrate REST API - createChannel to Typescript (#3786) * Chore: Migrate REST API - createChannel to Typescript * removed success * iserverroomitem --- app/definitions/rest/v1/channels.ts | 16 +++++++++++++++- app/definitions/rest/v1/groups.ts | 16 +++++++++++++++- app/lib/rocketchat/services/restApi.ts | 4 +--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/definitions/rest/v1/channels.ts b/app/definitions/rest/v1/channels.ts index d5270e0bc..640ade486 100644 --- a/app/definitions/rest/v1/channels.ts +++ b/app/definitions/rest/v1/channels.ts @@ -1,6 +1,6 @@ import { ITeam } from '../../ITeam'; import type { IMessage, IMessageFromServer } from '../../IMessage'; -import type { IRoom } from '../../IRoom'; +import type { IRoom, IServerRoomItem } from '../../IRoom'; import type { IUser } from '../../IUser'; export type ChannelsEndpoints = { @@ -29,6 +29,20 @@ export type ChannelsEndpoints = { messages: IMessageFromServer[]; }; }; + 'channels.create': { + POST: (params: { + name: string; + members: string[]; + readOnly: boolean; + extraData: { + broadcast: boolean; + encrypted: boolean; + teamId?: string; + }; + }) => { + group: Partial; + }; + }; 'channels.convertToTeam': { POST: (params: { channelId: string; channelName: string }) => { team: ITeam }; }; diff --git a/app/definitions/rest/v1/groups.ts b/app/definitions/rest/v1/groups.ts index d858d79d5..8868ac7de 100644 --- a/app/definitions/rest/v1/groups.ts +++ b/app/definitions/rest/v1/groups.ts @@ -1,6 +1,6 @@ import { ITeam } from '../../ITeam'; import type { IMessage, IMessageFromServer } from '../../IMessage'; -import type { IRoom } from '../../IRoom'; +import type { IRoom, IServerRoomItem } from '../../IRoom'; import type { IUser } from '../../IUser'; export type GroupsEndpoints = { @@ -23,6 +23,20 @@ export type GroupsEndpoints = { messages: IMessageFromServer[]; }; }; + 'groups.create': { + POST: (params: { + name: string; + members: string[]; + readOnly: boolean; + extraData: { + broadcast: boolean; + encrypted: boolean; + teamId?: string; + }; + }) => { + group: Partial; + }; + }; 'groups.convertToTeam': { POST: (params: { roomId: string; roomName: string }) => { team: ITeam }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 218d1faf0..a3f148f0a 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -19,7 +19,7 @@ export const createChannel = ({ broadcast: boolean; encrypted: boolean; teamId: string; -}): any => { +}) => { const params = { name, members: users, @@ -30,8 +30,6 @@ export const createChannel = ({ ...(teamId && { teamId }) } }; - // TODO: missing definitions from server - // @ts-ignore return sdk.post(type ? 'groups.create' : 'channels.create', params); };