diff --git a/src/helpers.ts b/src/helpers.ts index 24b77edc6..467e6ff4f 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -48,14 +48,14 @@ export function getTypeAndConversation(body: any): { type?: IncomingEventType, c conversationId: optionsBody.channel !== undefined ? optionsBody.channel.id : undefined, }; } - if (body.actions !== undefined || body.type === 'dialog_submission' || body.type === 'message_action') { + if (body.actions !== undefined || body.type === 'dialog_submission') { const actionBody = (body as SlackActionMiddlewareArgs['body']); return { type: IncomingEventType.Action, conversationId: actionBody.channel !== undefined ? actionBody.channel.id : undefined, }; } - if (body.type === 'shortcut') { + if (body.type === 'shortcut' || body.type === 'message_action') { return { type: IncomingEventType.Shortcut, }; diff --git a/src/middleware/builtin.ts b/src/middleware/builtin.ts index 6a3eec55c..3a3c79ba3 100644 --- a/src/middleware/builtin.ts +++ b/src/middleware/builtin.ts @@ -17,7 +17,7 @@ import { InteractiveMessage, DialogSubmitAction, GlobalShortcut, - MessageAction, + MessageShortcut, BlockElementAction, ContextMissingPropertyError, SlackViewAction, @@ -353,7 +353,7 @@ function isBlockPayload( type CallbackIdentifiedBody = | InteractiveMessage | DialogSubmitAction - | MessageAction + | MessageShortcut | GlobalShortcut | OptionsRequest<'interactive_message' | 'dialog_suggestion'>; diff --git a/src/types/actions/index.ts b/src/types/actions/index.ts index 0af300fc8..18dd3c71f 100644 --- a/src/types/actions/index.ts +++ b/src/types/actions/index.ts @@ -1,12 +1,10 @@ export * from './block-action'; export * from './interactive-message'; export * from './dialog-action'; -export * from './message-action'; import { BlockAction } from './block-action'; import { InteractiveMessage } from './interactive-message'; import { DialogSubmitAction, DialogValidation } from './dialog-action'; -import { MessageAction } from './message-action'; import { SayFn, SayArguments, RespondFn, AckFn } from '../utilities'; /** @@ -23,7 +21,7 @@ import { SayFn, SayArguments, RespondFn, AckFn } from '../utilities'; * offered when no generic parameter is bound would be limited to BasicElementAction rather than the union of known * actions - ElementAction. */ -export type SlackAction = BlockAction | InteractiveMessage | DialogSubmitAction | MessageAction; +export type SlackAction = BlockAction | InteractiveMessage | DialogSubmitAction; /** * Arguments which listeners and middleware receive to process an action from Slack's Block Kit interactive components, diff --git a/src/types/shortcuts/index.ts b/src/types/shortcuts/index.ts index 2c31101a9..13c3164d8 100644 --- a/src/types/shortcuts/index.ts +++ b/src/types/shortcuts/index.ts @@ -1,16 +1,20 @@ -export * from '../shortcuts/global-shortcut'; +// export * from './message-action'; +export * from './global-shortcut'; +export * from './message-shortcut'; -import { GlobalShortcut } from '../shortcuts/global-shortcut'; +import { MessageShortcut } from './message-shortcut'; +import { GlobalShortcut } from './global-shortcut'; import { SayFn, RespondFn, AckFn } from '../utilities'; /** * All known shortcuts from Slack. - * */ -export type SlackShortcut = GlobalShortcut; +export type SlackShortcut = GlobalShortcut | MessageShortcut; /** - * Arguments which listeners and middleware receive to process an shorcut from Slack. + * Arguments which listeners and middleware receive to process a shortcut from Slack. + * + * The type parameter `Shortcut` represents the entire JSON-encoded request body from Slack. */ export interface SlackShortcutMiddlewareArgs { payload: Shortcut; diff --git a/src/types/actions/message-action.ts b/src/types/shortcuts/message-shortcut.ts similarity index 96% rename from src/types/actions/message-action.ts rename to src/types/shortcuts/message-shortcut.ts index bb37e8ffb..a16a48caa 100644 --- a/src/types/actions/message-action.ts +++ b/src/types/shortcuts/message-shortcut.ts @@ -3,7 +3,7 @@ * * This describes the entire JSON-encoded body of a request from Slack message actions. */ -export interface MessageAction { +export interface MessageShortcut { type: 'message_action'; callback_id: string; trigger_id: string;