Skip to content

Commit 237ae6d

Browse files
committed
feat(add IssuesEvent && PullRequestEvent): also little fix to avoid redeclaration error and const override error (let to avoid ovveride error and declare before switch block to not get redeclare error)
1 parent 46fa4a3 commit 237ae6d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

app.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function getOneLineSummaryAndDescription(event) { // TODO: make logic to merge s
1919
const actorHref = `<a href="${actorAPIUrl}" target="_blank">${actorName}</a>`;
2020
const repoHref = `<a href="${repoAPIUrl}" target="_blank">${repoName}</a>`;
2121

22+
let action, issueHref, body;
23+
2224
const eventType = event.type;
2325
switch (eventType) {
2426
case 'WatchEvent':
@@ -43,17 +45,34 @@ function getOneLineSummaryAndDescription(event) { // TODO: make logic to merge s
4345
return actorHref + ' made ' + repoHref + ' public';
4446
case 'MemberEvent': // XXX: this event is not displayed in github normal feed, because it is offtopic naa
4547
const whomHref = `<a href="${event.payload.member.html_url}" target="_blank">${event.payload.member.login}</a>`;
46-
const action = event.payload.action;
48+
action = event.payload.action;
4749
return actorHref + ' ' + action + ' member ' + whomHref + ' to ' + repoHref;
4850

51+
case 'IssuesEvent':
52+
issueHref = `<a href="${event.payload.issue.html_url}" target="_blank">${event.payload.issue.title} #${event.payload.issue.number}</a>`
53+
action = event.payload.action;
54+
body = event.payload.issue.body
55+
body = body ? md.render(body) : ""; // TODO: limit render and add Read more url??
56+
return {
57+
summaryLine: `${actorHref} ${action} issue ${issueHref} on ${repoHref}`,
58+
description: body,
59+
}
4960
case 'IssueCommentEvent':
50-
const issueHref = `<a href="${event.payload.issue.html_url}" target="_blank">${event.payload.issue.title} #${event.payload.issue.number}</a>`;
51-
const body = md.render(event.payload.comment.body);
61+
issueHref = `<a href="${event.payload.issue.html_url}" target="_blank">${event.payload.issue.title} #${event.payload.issue.number}</a>`;
62+
body = md.render(event.payload.comment.body);
5263
return {
5364
summaryLine: actorHref + ' commented on ' + issueHref,
5465
description: body,
5566
};
5667

68+
case 'PullRequestEvent':
69+
prHref = `<a href="${event.payload.pull_request.html_url}" target="_blank">${event.payload.pull_request.title} #${event.payload.pull_request.number}</a>`;
70+
action = event.payload.action;
71+
return {
72+
summaryLine: `${actorHref} ${action} pull request ${prHref} on ${repoHref}`,
73+
description: "NO DESCRIPTION -> TODO: limit render lines because this is a feed",
74+
}
75+
5776
// INFO: below events are identified by AI assistant, but i didn't find them in my feed api
5877
// case 'PullRequestEvent':
5978
// return 'opened a pull request';

0 commit comments

Comments
 (0)