dont break on ci alerts

This commit is contained in:
Nicholas Zuber 2023-02-04 19:48:44 -05:00
parent 32d7c35f57
commit f87f33b591
2 changed files with 37 additions and 10 deletions

View File

@ -3,7 +3,7 @@
"version": "1.0.0", "version": "1.0.0",
"private": true, "private": true,
"engines": { "engines": {
"node": "12.x" "node": "16.x"
}, },
"dependencies": { "dependencies": {
"@emotion/core": "^10.0.10", "@emotion/core": "^10.0.10",

View File

@ -8,10 +8,14 @@ const BASE_GITHUB_API_URL = 'https://api.github.com';
const PER_PAGE = 50; const PER_PAGE = 50;
function transformUrlFromResponse(url) { function transformUrlFromResponse(url) {
return url try {
.replace('api.github.com', 'github.com') return url
.replace('/repos/', '/') .replace('api.github.com', 'github.com')
.replace('/pulls/', '/pull/'); .replace('/repos/', '/')
.replace('/pulls/', '/pull/');
} catch (err) {
return url || ""
}
} }
function processHeadersAndBodyJson(response) { function processHeadersAndBodyJson(response) {
@ -171,10 +175,7 @@ class NotificationsProvider extends React.Component {
// //
// 1 month is pretty arbitrary, we can raise this if we want. // 1 month is pretty arbitrary, we can raise this if we want.
const since = const since =
moment() moment().subtract(1, 'month').toISOString().split('.')[0] + 'Z';
.subtract(1, 'month')
.toISOString()
.split('.')[0] + 'Z';
const headers = { const headers = {
Authorization: `token ${this.props.token}`, Authorization: `token ${this.props.token}`,
@ -209,7 +210,33 @@ class NotificationsProvider extends React.Component {
if (links && links.next && links.next.page) { if (links && links.next && links.next.page) {
nextPage = links.next.page; nextPage = links.next.page;
} }
return this.processNotificationsChunk(nextPage, json);
const chunk = json.filter(notification => {
// 2/4/2023
// New reasons have joined the party.
// Restrict some reasons to maintain backwards compat.
const allowedReasons = [
"assign",
"author",
"comment",
// "ci_activity",
// "invitation",
// "manual",
"mention",
"review_requested",
// "security_alert",
"state_change",
"subscribed",
"team_mention"
]
if (allowedReasons.includes(notification.reason)) {
return true
} else {
return false
}
})
return this.processNotificationsChunk(nextPage, chunk);
}); });
}; };