|
1 | 1 | import type { IRoom } from '@rocket.chat/apps-engine/definition/rooms/IRoom'; |
2 | 2 | import type { ISlashCommand } from '@rocket.chat/apps-engine/definition/slashcommands/ISlashCommand'; |
3 | | -import type { SlashCommandContext as _SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext'; |
4 | | -import type { Room as _Room } from '@rocket.chat/apps-engine/server/rooms/Room'; |
| 3 | +import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext'; |
5 | 4 | import { Defined, JsonRpcError } from 'jsonrpc-lite'; |
6 | 5 |
|
7 | 6 | import { AppObjectRegistry } from '../AppObjectRegistry.ts'; |
8 | 7 | import { AppAccessors, AppAccessorsInstance } from '../lib/accessors/mod.ts'; |
9 | | -import { require } from '../lib/require.ts'; |
10 | 8 | import createRoom from '../lib/roomFactory.ts'; |
11 | 9 | import { RequestContext } from '../lib/requestContext.ts'; |
12 | 10 | import { wrapComposedApp } from '../lib/wrapAppForRequest.ts'; |
13 | 11 |
|
14 | | -// For some reason Deno couldn't understand the typecast to the original interfaces and said it wasn't a constructor type |
15 | | -const { SlashCommandContext } = require('@rocket.chat/apps-engine/definition/slashcommands/SlashCommandContext.js') as { |
16 | | - SlashCommandContext: typeof _SlashCommandContext; |
17 | | -}; |
18 | | - |
19 | 12 | export default async function slashCommandHandler(request: RequestContext): Promise<JsonRpcError | Defined> { |
20 | 13 | const { method: call, params } = request; |
21 | 14 | const { logger } = request.context; |
@@ -76,11 +69,11 @@ export function handleExecutor(deps: Deps, command: ISlashCommand, method: 'exec |
76 | 69 | const { sender, room, params: args, threadId, triggerId } = params[0] as Record<string, unknown>; |
77 | 70 |
|
78 | 71 | const context = new SlashCommandContext( |
79 | | - sender as _SlashCommandContext['sender'], |
| 72 | + sender as SlashCommandContext['sender'], |
80 | 73 | createRoom(room as IRoom, deps.AppAccessorsInstance.getSenderFn()), |
81 | | - args as _SlashCommandContext['params'], |
82 | | - threadId as _SlashCommandContext['threadId'], |
83 | | - triggerId as _SlashCommandContext['triggerId'], |
| 74 | + args as SlashCommandContext['params'], |
| 75 | + threadId as SlashCommandContext['threadId'], |
| 76 | + triggerId as SlashCommandContext['triggerId'], |
84 | 77 | ); |
85 | 78 |
|
86 | 79 | return executor.apply(wrapComposedApp(command, deps.request), [ |
@@ -109,11 +102,11 @@ export function handlePreviewItem(deps: Deps, command: ISlashCommand, params: un |
109 | 102 | const [previewItem, { sender, room, params: args, threadId, triggerId }] = params as [Record<string, unknown>, Record<string, unknown>]; |
110 | 103 |
|
111 | 104 | const context = new SlashCommandContext( |
112 | | - sender as _SlashCommandContext['sender'], |
| 105 | + sender as SlashCommandContext['sender'], |
113 | 106 | createRoom(room as IRoom, deps.AppAccessorsInstance.getSenderFn()), |
114 | | - args as _SlashCommandContext['params'], |
115 | | - threadId as _SlashCommandContext['threadId'], |
116 | | - triggerId as _SlashCommandContext['triggerId'], |
| 107 | + args as SlashCommandContext['params'], |
| 108 | + threadId as SlashCommandContext['threadId'], |
| 109 | + triggerId as SlashCommandContext['triggerId'], |
117 | 110 | ); |
118 | 111 |
|
119 | 112 | return command.executePreviewItem.call( |
|
0 commit comments