File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,17 @@ export async function POST(req: NextRequest): Promise<Response> {
3636 }
3737
3838 const data = SlackWebhookRequestSchema . parse ( payload ) ;
39- if ( data . type === "url_verification" ) {
40- return NextResponse . json ( { challenge : data . challenge } ) ;
41- }
4239
43- if ( data . type === "event_callback" ) {
44- const { event, team_id } = data ;
45- await processSlackEvent ( { event, teamId : team_id } ) ;
46- return NextResponse . json ( { ok : true } , { status : 200 } ) ;
40+ if ( "type" in data ) {
41+ if ( data . type === "url_verification" ) {
42+ return NextResponse . json ( { challenge : data . challenge } ) ;
43+ }
44+
45+ if ( data . type === "event_callback" ) {
46+ const { event, team_id } = data ;
47+ await processSlackEvent ( { event, teamId : team_id } ) ;
48+ return NextResponse . json ( { ok : true } , { status : 200 } ) ;
49+ }
4750 }
4851
4952 return NextResponse . json ( { ok : true } , { status : 200 } ) ;
Original file line number Diff line number Diff line change @@ -87,4 +87,12 @@ export const SlackSlashCommandSchema = z.looseObject({
8787 is_enterprise_install : z . string ( ) . optional ( ) ,
8888} ) ;
8989
90- export const SlackWebhookRequestSchema = z . union ( [ SlackUrlVerificationRequestSchema , SlackEventCallbackSchema ] ) ;
90+ export const SlackBlockActionsSchema = z . object ( {
91+ payload : z . string ( ) ,
92+ } ) ;
93+
94+ export const SlackWebhookRequestSchema = z . union ( [
95+ SlackUrlVerificationRequestSchema ,
96+ SlackEventCallbackSchema ,
97+ SlackBlockActionsSchema ,
98+ ] ) ;
You can’t perform that action at this time.
0 commit comments