Skip to content

Commit

Permalink
Updates title to callbackId (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
srajiang committed Aug 31, 2022
1 parent 144b71e commit b22a7fd
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/SlackFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,36 @@ export type AllSlackFunctionExecutedMiddlewareArgs = SlackFunctionExecutedMiddle
* A Function is a deterministic machine with
* specified outputs given specific inputs.
* --
* You configure a Function's title, inputs, and outputs
* in your project's manifest file (json or js). If your project contains any
* functions via app.function, it must have a corresponding
* manifest entry or App will throw an error when attempting to
* initialize.
* You configure a Function's callback_id, inputs, and outputs
* in your project's manifest file (json or js).
* --
* Slack will take care of providing inputs to your function
* via a function_execution event. Bolt handles delivering those
* to your function in the way you can expect of regular events,
* messages, shortcuts commands, etc.
* --
* When initiating an instance of Function below, you supply the
* fn you want to process the supplied inputs and what logical
* callback you want to process the supplied inputs and what logical
* conditions determine success or failure in your use case.
* You must call the supplied utility success with your specified
* outputs or failure.
* Call the supplied utilities completeSuccess with your specified
* outputs or completeError.
* */
export class SlackFunction {
/**
* @description The named title of the function
* Should correspond to manifest file
* @description The callback_id of the function
* as defined in your manifest file
* */
private title: string;
private callbackId: string;

/**
* @description fn to to process corresponding
* function_executed event
*/
private fn: Middleware<SlackEventMiddlewareArgs>;

public constructor(title: string, fn: Middleware<SlackEventMiddlewareArgs>) {
public constructor(callbackId: string, fn: Middleware<SlackEventMiddlewareArgs>) {
// TODO: Add validation step
this.title = title;
this.callbackId = callbackId;
this.fn = fn;
}

Expand All @@ -72,7 +69,7 @@ export class SlackFunction {

private matchesConstraints(args: AnyMiddlewareArgs): boolean {
if ('function' in args.payload) {
return this.title === args.payload.function.callback_id;
return this.callbackId === args.payload.function.callback_id;
}
return false;
}
Expand Down

0 comments on commit b22a7fd

Please sign in to comment.