Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8939,8 +8939,17 @@ function getCommandsFromComment(body) {
exports.getCommandsFromComment = getCommandsFromComment;
function inTeam(org, username, team) {
return __awaiter(this, void 0, void 0, function* () {
const members = yield octokit_1.default.teams.listMembersInOrg({ org, team_slug: team });
return members.data.map(m => m.login).includes(username);
try {
const members = yield octokit_1.default.teams.listMembersInOrg({ org, team_slug: team });
return members.data.map(m => m.login).includes(username);
}
catch (e) {
if (e.status === 404) {
console.warn(`404 while fetching members of '${team}' team`);
return false;
}
throw e;
}
});
}
exports.inTeam = inTeam;
Expand Down
13 changes: 11 additions & 2 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ export function getCommandsFromComment(body: string): Command[] {
}

export async function inTeam(org: string, username: string, team: string) {
const members = await octokit.teams.listMembersInOrg({ org, team_slug: team });
try {
const members = await octokit.teams.listMembersInOrg({ org, team_slug: team });

return members.data.map(m => m.login).includes(username);
} catch (e) {
if ((e as RequestError).status === 404) {
console.warn(`404 while fetching members of '${team}' team`);
return false;
}

return members.data.map(m => m.login).includes(username);
throw e;
}
}

export async function isMaintainer(org: string, username: string) {
Expand Down