Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #928 from gentlementlegen/fix/crash-on-missing-mem…
Browse files Browse the repository at this point in the history
…bership

fix: crash on missing membership
  • Loading branch information
gentlementlegen authored May 23, 2024
2 parents e45abb5 + ceb6d6e commit 7ac43a3
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,19 @@ export async function isUserAdminOrBillingManager(

async function checkIfIsBillingManager() {
if (!payload.organization) throw context.logger.fatal(`No organization found in payload!`);
const { data: membership } = await context.octokit.rest.orgs.getMembershipForUser({
org: payload.organization.login,
username: payload.repository.owner.login,
});

console.trace(membership);
if (membership.role === "billing_manager") {
return true;
} else {
try {
const { data: membership } = await context.octokit.rest.orgs.getMembershipForUser({
org: payload.organization.login,
username: payload.repository.owner.login,
});

console.trace(membership);
return membership.role === "billing_manager";
} catch (e) {
context.logger.error(
`Could not get the Billing Manager status for ${payload.repository.owner.login} within ${payload.organization.login}`,
e
);
return false;
}
}
Expand Down

0 comments on commit 7ac43a3

Please sign in to comment.