feat: added custom block action handler
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
CreateIssueModalViewProjects,
|
||||
} from "../utils/slack/create-issue-modal";
|
||||
import { ProjectService } from "../services/project.service";
|
||||
import { convertProjectToOptions } from "../utils/slack/convert-project-to-options";
|
||||
import { convertToSlackOptions } from "../utils/slack/convert-to-slack-options";
|
||||
import { processSlackPayload } from "../handlers/slack/core";
|
||||
import { TSlackPayload } from "types/slack";
|
||||
|
||||
@@ -55,7 +55,7 @@ export class SlackController {
|
||||
|
||||
const projectList =
|
||||
await projectService.getProjectsForWorkspace(workspaceId);
|
||||
const projectPlainTextOption = convertProjectToOptions(projectList);
|
||||
const projectPlainTextOption = convertToSlackOptions(projectList);
|
||||
|
||||
await slackService.openModal(
|
||||
req.body.trigger_id,
|
||||
@@ -67,17 +67,12 @@ export class SlackController {
|
||||
@Post("events")
|
||||
async handleSlackEvents(req: Request, res: Response) {
|
||||
const payload = JSON.parse(req.body.payload) as TSlackPayload;
|
||||
const success = processSlackPayload(payload);
|
||||
const success = await processSlackPayload(payload);
|
||||
|
||||
if (!success) {
|
||||
console.log("error");
|
||||
res.sendStatus(500);
|
||||
}
|
||||
|
||||
// const selectedProjectId = payload.actions[0].selected_option.value;
|
||||
// const states = await projectService.getProjectStates(selectedProjectId);
|
||||
// const members = await projectService.getProjectMembers(selectedProjectId);
|
||||
// const labels = await projectService.getProjectLabels(selectedProjectId);
|
||||
|
||||
res.sendStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { drizzle, PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "./slack.schema";
|
||||
import * as schema from "./schema";
|
||||
// logger
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { TBlockActionPayload } from "types/slack";
|
||||
import { TBlockActionModalPayload, TBlockActionPayload } from "types/slack";
|
||||
import { handleProjectSelectAction } from "./blockActions/handle-project-select-action";
|
||||
|
||||
export const handleBlockAction = async (
|
||||
payload: TBlockActionPayload,
|
||||
): Promise<boolean> => {};
|
||||
): Promise<boolean> => {
|
||||
switch (payload.actions[0].action_id) {
|
||||
case "project-select-action":
|
||||
// When a user selects a project from the dropdown in create issue, this is the action that is triggered.
|
||||
return await handleProjectSelectAction(
|
||||
payload as TBlockActionModalPayload,
|
||||
);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { TSlackPayload } from "types/slack";
|
||||
import { handleBlockAction } from "./block-action-handler";
|
||||
import { handleViewClosed } from "./view-close-handler";
|
||||
import { handleViewSubmission } from "./view-submission-handler";
|
||||
|
||||
export const processSlackPayload = async (payload: any): Promise<boolean> => {
|
||||
export const processSlackPayload = async (
|
||||
payload: TSlackPayload,
|
||||
): Promise<boolean> => {
|
||||
switch (payload.type) {
|
||||
case "block_actions":
|
||||
return await handleBlockAction(payload);
|
||||
|
||||
Reference in New Issue
Block a user