diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index c8c4160e3..edbb76d5a 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -638,12 +638,12 @@ class MessageBox extends Component { }, 1000); }; - setCommandPreview = async (command: any, name: string, params: any) => { + setCommandPreview = async (command: any, name: string, params: string) => { const { rid } = this.props; try { - const { success, preview } = await RocketChat.getCommandPreview(name, rid, params); - if (success) { - return this.setState({ commandPreview: preview?.items, showCommandPreview: true, command }); + const response = await RocketChat.getCommandPreview(name, rid, params); + if (response.success) { + return this.setState({ commandPreview: response.preview?.items, showCommandPreview: true, command }); } } catch (e) { log(e); diff --git a/app/definitions/rest/v1/commands.ts b/app/definitions/rest/v1/commands.ts new file mode 100644 index 000000000..2aa9dabd6 --- /dev/null +++ b/app/definitions/rest/v1/commands.ts @@ -0,0 +1,10 @@ +export type CommandsEndpoints = { + 'commands.preview': { + GET: (params: { command: string; roomId: string; params: string }) => { + preview: { + i18nTitle: string; + items: any; + }; + }; + }; +}; diff --git a/app/definitions/rest/v1/index.ts b/app/definitions/rest/v1/index.ts index 4e899f106..dc1cdcd0d 100644 --- a/app/definitions/rest/v1/index.ts +++ b/app/definitions/rest/v1/index.ts @@ -16,6 +16,7 @@ import { TeamsEndpoints } from './teams'; import { E2eEndpoints } from './e2e'; import { SubscriptionsEndpoints } from './subscriptions'; import { VideoConferenceEndpoints } from './videoConference'; +import { CommandsEndpoints } from './commands'; export type Endpoints = ChannelsEndpoints & ChatEndpoints & @@ -34,4 +35,5 @@ export type Endpoints = ChannelsEndpoints & TeamsEndpoints & E2eEndpoints & SubscriptionsEndpoints & - VideoConferenceEndpoints; + VideoConferenceEndpoints & + CommandsEndpoints; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 30a896a4b..38754af63 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -686,10 +686,8 @@ export const runSlashCommand = (command: string, roomId: string, params: any, tr tmid }); -export const getCommandPreview = (command: string, roomId: string, params: any): any => +export const getCommandPreview = (command: string, roomId: string, params: string) => // RC 0.65.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get('commands.preview', { command, roomId,