File tree 4 files changed +12
-15
lines changed
src/api-utils/midddleware
4 files changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export const parseSlackActionPayloadMiddleware = {
48
48
} ;
49
49
export const parseSlackEventPayloadMiddleware = {
50
50
method : parseSlackEventPayload ,
51
- assign : 'slackActionPayload ' ,
51
+ assign : 'slackEventsPayload ' ,
52
52
} ;
53
53
54
54
export const parseSlackSlashCommandPayloadMiddleware = {
Original file line number Diff line number Diff line change 1
- import Querystring from 'querystring' ;
1
+ // import Querystring from 'querystring';
2
2
3
3
import Boom from '@hapi/boom' ;
4
4
import type { Lifecycle , Request } from '@hapi/hapi' ;
@@ -20,16 +20,15 @@ export function parseSlackActionPayload(request: Request): Lifecycle.Method {
20
20
throw Boom . internal ( 'Payload is not a Buffer' ) ;
21
21
}
22
22
23
- const body = request . payload . toString ( 'utf-8' ) ;
24
- const { payload } = Querystring . parse ( body ) ;
23
+ const body = new URLSearchParams ( request . payload . toString ( 'utf-8' ) ) ;
24
+ const payload = body . get ( 'payload' ) ;
25
25
26
26
const parsed :
27
27
| SlackActionsPayload
28
28
| SlackDialogsPayload
29
29
| SlackBlockKitPayload
30
30
| SlackShortcutPayload
31
- | SlackDialogSubmissionPayload = JSON . parse ( payload as string ) ;
32
-
31
+ | SlackDialogSubmissionPayload = JSON . parse ( payload || '' ) ;
33
32
let mutableSlackPayload ;
34
33
switch ( parsed . type ) {
35
34
case 'message_action' :
Original file line number Diff line number Diff line change 1
- import Querystring from 'querystring' ;
2
-
3
1
import Boom from '@hapi/boom' ;
4
2
import type { Lifecycle } from '@hapi/hapi' ;
5
3
@@ -14,10 +12,10 @@ export const parseSlackEventPayload: Lifecycle.Method = (request) => {
14
12
throw Boom . internal ( 'Payload is not a Buffer' ) ;
15
13
}
16
14
17
- const body = request . payload . toString ( 'utf-8' ) ;
18
- const { payload } = Querystring . parse ( body ) ;
15
+ const body = new URLSearchParams ( request . payload . toString ( 'utf-8' ) ) ;
16
+ const payload = body . get ( 'payload' ) ;
19
17
20
- const parsed : SlackChallengesPayload | SlackEventsPayload = JSON . parse ( payload as string ) ;
18
+ const parsed : SlackChallengesPayload | SlackEventsPayload = JSON . parse ( payload || '' ) ;
21
19
22
20
const slackEventPayload = parsed . challenge
23
21
? slackChallengesPayloadSchema . validate ( parsed , { stripUnknown : true } )
Original file line number Diff line number Diff line change 1
- import Querystring from 'querystring' ;
2
-
3
1
import Boom from '@hapi/boom' ;
4
2
import type { Lifecycle , Request } from '@hapi/hapi' ;
5
3
@@ -12,8 +10,10 @@ export function parseSlackSlashCommandPayload(request: Request): Lifecycle.Metho
12
10
throw Boom . internal ( 'Payload is not a Buffer' ) ;
13
11
}
14
12
15
- const body = request . payload . toString ( 'utf-8' ) ;
16
- const parsed = Querystring . parse ( body ) as unknown as SlackSlashCommandPayload ;
13
+ const body = new URLSearchParams ( request . payload . toString ( 'utf-8' ) ) ;
14
+ const payload = { } as any ;
15
+ body . forEach ( ( value , name ) => ( payload [ name ] = value ) ) ;
16
+ const parsed = payload as SlackSlashCommandPayload ;
17
17
18
18
const slashCommandPayload = slackSlashCommandPayloadSchema . validate ( parsed , {
19
19
stripUnknown : true ,
You can’t perform that action at this time.
0 commit comments