Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Sep 26, 2023
1 parent 258e55d commit 5d014c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class Bot {

async canTriggerBot() {

Check failure on line 23 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`

Check failure on line 23 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
this.logger.debug("Evaluating if user can trigger the bot");

Check failure on line 24 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `········` with `····`
const author = this.pr.user.id;
if (this.comment.user.id === author) {
this.logger.debug("Author of comment is also author of PR")
return true;
}
// const author = this.pr.user.id;

Check failure on line 25 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `····`
// if (this.comment.user.id === author) {

Check failure on line 26 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `········` with `····`
// this.logger.debug("Author of comment is also author of PR")

Check failure on line 27 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `····`
// return true;

Check failure on line 28 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `········` with `····`
// }

Check failure on line 29 in src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `····`
this.logger.debug("Author of comment is not the author of the PR");

return await this.commentsApi.userBelongsToOrg(this.comment.user.login);
Expand Down
15 changes: 13 additions & 2 deletions src/github/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ export class CommentsApi {
await this.api.rest.reactions.createForIssueComment({ ...this.pullData, comment_id: commentId, content: reaction });
}

async userBelongsToOrg(username:string):Promise<boolean> {
const check = await this.api.rest.orgs.listForUser({username, per_page: 100});
async userBelongsToOrg(username: string): Promise<boolean> {
// const members = [];
// for

// const membersCall = await this.api.rest.orgs.listPublicMembers({org:"polkadot-fellows", per_page: 100});

for (const org of ["paritytech", "polkadot-fellows", "paritytech-stg"]) {
console.log("Checking", org);
const data = await this.api.rest.orgs.checkPublicMembershipForUser({ org, username });;
console.log("Public members data:", org, data.data, data);
}

const check = await this.api.rest.orgs.listForUser({ username, per_page: 100 });
const orgs = check.data.map(org => org.login);
this.logger.info("User belong to the following orgs: " + JSON.stringify(orgs));
return orgs.some((org) => org === this.pullData.owner);
Expand Down

0 comments on commit 5d014c9

Please sign in to comment.