@@ -89,7 +89,7 @@ function checkForParsableGithubLink(message) {
89
89
return [ true , owner , name , type , id ] ;
90
90
}
91
91
92
- return [ false ] ;
92
+ return [ false ] ;
93
93
}
94
94
95
95
/**
@@ -334,41 +334,48 @@ async function parseGithubLink(message, parsable) {
334
334
async function parseQuery ( members , response ) {
335
335
const parsedCardData = await Promise . all (
336
336
await response . map ( async ( items ) => {
337
- if ( Utils . isPropertyExist ( items , 'state' ) ) {
338
- if ( items . state === 'NOTE_ONLY' ) {
339
- if ( Utils . isPropertyExist ( items , 'note' ) && Utils . isPropertyExist ( items , 'creator' ) ) {
340
- for ( let i = 0 ; i < members . length ; i ++ ) {
341
- if ( items . note . includes ( `@${ members [ i ] . name } ` ) ) {
342
- const parsable = checkForParsableGithubLink ( items . note ) ;
343
-
344
- return parsable [ 0 ]
345
- ? await parseGithubLink ( items . note , parsable )
346
- : escapeChars ( items . note ) ;
337
+ try {
338
+ if ( Utils . isPropertyExist ( items , 'state' ) ) {
339
+ if ( items . state === 'NOTE_ONLY' ) {
340
+ if ( Utils . isPropertyExist ( items , 'note' ) && Utils . isPropertyExist ( items , 'creator' ) ) {
341
+ for ( let i = 0 ; i < members . length ; i ++ ) {
342
+ if ( items . note . includes ( `@${ members [ i ] . name } ` ) ) {
343
+ const parsable = checkForParsableGithubLink ( items . note ) ;
344
+
345
+ return parsable [ 0 ]
346
+ ? await parseGithubLink ( items . note , parsable )
347
+ : escapeChars ( items . note ) ;
348
+ }
347
349
}
348
- }
349
- const parsable = checkForParsableGithubLink ( items . note ) ;
350
+ const parsable = checkForParsableGithubLink ( items . note ) ;
350
351
351
- return parsable [ 0 ]
352
- ? await parseGithubLink ( items . note , parsable )
353
- : `${ items . note } @${ items . creator . login } ` ;
354
- }
355
- } else if ( items . state === 'CONTENT_ONLY' ) {
356
- if ( Utils . isPropertyExist ( items , 'content' , '__typename' ) ) {
357
- if ( items . content . __typename === 'PullRequest' ) {
358
- return pullRequestParser ( items . content ) ;
352
+ return parsable [ 0 ]
353
+ ? await parseGithubLink ( items . note , parsable )
354
+ : `${ items . note } @${ items . creator . login } ` ;
359
355
}
360
- if ( items . content . __typename === 'Issue' ) {
361
- return issuesParser ( items . content ) ;
356
+ } else if ( items . state === 'CONTENT_ONLY' ) {
357
+ if ( Utils . isPropertyExist ( items , 'content' , '__typename' ) ) {
358
+ if ( items . content . __typename === 'PullRequest' ) {
359
+ return pullRequestParser ( items . content ) ;
360
+ }
361
+
362
+ if ( items . content . __typename === 'Issue' ) {
363
+ return issuesParser ( items . content ) ;
364
+ }
362
365
}
363
366
}
364
- }
365
367
366
- return '' ;
368
+ return '' ;
369
+ }
370
+ } catch ( e ) {
371
+ HawkCatcher . send ( e , {
372
+ cardData : items ,
373
+ } ) ;
367
374
}
368
375
} )
369
- ) ;
376
+ ) . catch ( HawkCatcher . send ) ;
370
377
371
- let cardDataWithoutMembers = [ ...parsedCardData ] ;
378
+ let cardDataWithoutMembers = [ ...parsedCardData ] ;
372
379
373
380
for ( let i = 0 ; i < members . length ; i ++ ) {
374
381
cardDataWithoutMembers = cardDataWithoutMembers . map ( ( x ) =>
@@ -495,60 +502,56 @@ function parseMeetingMessage(mentionList) {
495
502
* Call the Github GraphQL API, parse its response to message and add that message as cron job.
496
503
*/
497
504
async function main ( ) {
498
- try {
499
- const toDoJob = new CronJob (
500
- TO_DO_TIME ,
501
- async ( ) => {
502
- notify (
503
- await notifyMessage ( "📌 Sprint's backlog" , COLUMN_NODE_ID_TO_DO , true )
504
- )
505
- . then ( ( ) => console . log ( 'Tasks Job Completed.' ) )
506
- . catch ( HawkCatcher . send ) ;
507
- } ,
508
- null ,
509
- true ,
510
- 'Europe/Moscow'
511
- ) ;
505
+ const toDoJob = new CronJob (
506
+ TO_DO_TIME ,
507
+ async ( ) => {
508
+ notify (
509
+ await notifyMessage ( "📌 Sprint's backlog" , COLUMN_NODE_ID_TO_DO , true )
510
+ )
511
+ . then ( ( ) => console . log ( 'Tasks Job Completed.' ) )
512
+ . catch ( HawkCatcher . send ) ;
513
+ } ,
514
+ null ,
515
+ true ,
516
+ 'Europe/Moscow'
517
+ ) ;
512
518
513
- const prJob = new CronJob (
514
- PR_TIME ,
515
- async ( ) => {
516
- notify (
517
- await notifyMessage ( '👀 Pull requests for review' , COLUMN_NODE_ID_PR )
518
- )
519
- . then ( ( ) => console . log ( 'PR Job Completed.' ) )
520
- . catch ( HawkCatcher . send ) ;
521
- } ,
522
- null ,
523
- true ,
524
- 'Europe/Moscow'
525
- ) ;
526
- const meetingJob = new CronJob (
527
- MEETING_TIME ,
528
- ( ) => {
529
- notify ( parseMeetingMessage ( MEETING_MENTION ) )
530
- . then ( ( ) => console . log ( 'Meeting Job Completed.' ) )
531
- . catch ( HawkCatcher . send ) ;
532
- } ,
533
- null ,
534
- true ,
535
- 'Europe/Moscow'
536
- ) ;
519
+ const prJob = new CronJob (
520
+ PR_TIME ,
521
+ async ( ) => {
522
+ notify (
523
+ await notifyMessage ( '👀 Pull requests for review' , COLUMN_NODE_ID_PR )
524
+ )
525
+ . then ( ( ) => console . log ( 'PR Job Completed.' ) )
526
+ . catch ( HawkCatcher . send ) ;
527
+ } ,
528
+ null ,
529
+ true ,
530
+ 'Europe/Moscow'
531
+ ) ;
532
+ const meetingJob = new CronJob (
533
+ MEETING_TIME ,
534
+ ( ) => {
535
+ notify ( parseMeetingMessage ( MEETING_MENTION ) )
536
+ . then ( ( ) => console . log ( 'Meeting Job Completed.' ) )
537
+ . catch ( HawkCatcher . send ) ;
538
+ } ,
539
+ null ,
540
+ true ,
541
+ 'Europe/Moscow'
542
+ ) ;
537
543
538
- toDoJob . start ( ) ;
539
- console . log ( 'To do list Notifier started' ) ;
540
- console . log ( 'Will notify at:' + TO_DO_TIME ) ;
544
+ toDoJob . start ( ) ;
545
+ console . log ( 'To do list Notifier started' ) ;
546
+ console . log ( 'Will notify at:' + TO_DO_TIME ) ;
541
547
542
- prJob . start ( ) ;
543
- console . log ( 'PR review list Notifier started' ) ;
544
- console . log ( 'Will notify at:' + PR_TIME ) ;
548
+ prJob . start ( ) ;
549
+ console . log ( 'PR review list Notifier started' ) ;
550
+ console . log ( 'Will notify at:' + PR_TIME ) ;
545
551
546
- meetingJob . start ( ) ;
547
- console . log ( 'Meeting notifier started' ) ;
548
- console . log ( 'Will notify at:' + MEETING_TIME ) ;
549
- } catch ( e ) {
550
- HawkCatcher . send ( e ) ;
551
- }
552
+ meetingJob . start ( ) ;
553
+ console . log ( 'Meeting notifier started' ) ;
554
+ console . log ( 'Will notify at:' + MEETING_TIME ) ;
552
555
}
553
556
554
557
main ( ) ;
0 commit comments