File tree Expand file tree Collapse file tree 1 file changed +25
-10
lines changed Expand file tree Collapse file tree 1 file changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,30 @@ const lambda = new AWS.Lambda()
5
5
6
6
const isMessageForBot = require ( './utils/isMessageForBot' )
7
7
8
+ function invokeLambda ( payload ) {
9
+ const processIssueCommentPayload = JSON . stringify ( payload )
10
+
11
+ return new Promise ( function ( resolve , reject ) {
12
+ lambda . invoke (
13
+ {
14
+ FunctionName : `${
15
+ process . env . SERVICE_NAME_AND_STAGE
16
+ } -processIssueComment`,
17
+ InvocationType : 'Event' ,
18
+ LogType : 'None' ,
19
+ Payload : new Buffer ( processIssueCommentPayload ) ,
20
+ } ,
21
+ function ( error , data ) {
22
+ if ( error ) {
23
+ reject ( error )
24
+ } else {
25
+ resolve ( data )
26
+ }
27
+ } ,
28
+ )
29
+ } )
30
+ }
31
+
8
32
module . exports . handler = async ( event , context ) => {
9
33
context . callbackWaitsForEmptyEventLoop = false
10
34
@@ -43,20 +67,11 @@ module.exports.handler = async (event, context) => {
43
67
}
44
68
}
45
69
46
- const processIssueCommentPayload = JSON . stringify ( {
70
+ await invokeLambda ( {
47
71
name,
48
72
payload,
49
73
} )
50
74
51
- lambda . invoke ( {
52
- FunctionName : `${
53
- process . env . SERVICE_NAME_AND_STAGE
54
- } -processIssueComment`,
55
- InvocationType : 'Event' ,
56
- LogType : 'None' ,
57
- Payload : new Buffer ( processIssueCommentPayload ) ,
58
- } )
59
-
60
75
return {
61
76
statusCode : 200 ,
62
77
body : 'Accepted and processing comment' ,
You can’t perform that action at this time.
0 commit comments