Skip to content

Commit

Permalink
moved message actions to shorcut method
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed Mar 19, 2020
1 parent 6df7d37 commit 4b7a994
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SlackAction>['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,
};
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/builtin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
InteractiveMessage,
DialogSubmitAction,
GlobalShortcut,
MessageAction,
MessageShortcut,
BlockElementAction,
ContextMissingPropertyError,
SlackViewAction,
Expand Down Expand Up @@ -353,7 +353,7 @@ function isBlockPayload(
type CallbackIdentifiedBody =
| InteractiveMessage
| DialogSubmitAction
| MessageAction
| MessageShortcut
| GlobalShortcut
| OptionsRequest<'interactive_message' | 'dialog_suggestion'>;

Expand Down
4 changes: 1 addition & 3 deletions src/types/actions/index.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand All @@ -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,
Expand Down
14 changes: 9 additions & 5 deletions src/types/shortcuts/index.ts
Original file line number Diff line number Diff line change
@@ -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<Shortcut extends SlackShortcut = SlackShortcut> {
payload: Shortcut;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4b7a994

Please sign in to comment.