Skip to content

Commit 6774c07

Browse files
committed
HawkCatcher for perticular card added
1 parent d184a9c commit 6774c07

File tree

1 file changed

+80
-77
lines changed

1 file changed

+80
-77
lines changed

src/index.js

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function checkForParsableGithubLink(message) {
8989
return [true, owner, name, type, id];
9090
}
9191

92-
return [false];
92+
return [ false ];
9393
}
9494

9595
/**
@@ -334,41 +334,48 @@ async function parseGithubLink(message, parsable) {
334334
async function parseQuery(members, response) {
335335
const parsedCardData = await Promise.all(
336336
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+
}
347349
}
348-
}
349-
const parsable = checkForParsableGithubLink(items.note);
350+
const parsable = checkForParsableGithubLink(items.note);
350351

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}`;
359355
}
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+
}
362365
}
363366
}
364-
}
365367

366-
return '';
368+
return '';
369+
}
370+
} catch (e) {
371+
HawkCatcher.send(e, {
372+
cardData: items,
373+
});
367374
}
368375
})
369-
);
376+
).catch(HawkCatcher.send);
370377

371-
let cardDataWithoutMembers = [...parsedCardData];
378+
let cardDataWithoutMembers = [ ...parsedCardData ];
372379

373380
for (let i = 0; i < members.length; i++) {
374381
cardDataWithoutMembers = cardDataWithoutMembers.map((x) =>
@@ -495,60 +502,56 @@ function parseMeetingMessage(mentionList) {
495502
* Call the Github GraphQL API, parse its response to message and add that message as cron job.
496503
*/
497504
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+
);
512518

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+
);
537543

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);
541547

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);
545551

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);
552555
}
553556

554557
main();

0 commit comments

Comments
 (0)