diff --git a/src/bot.ts b/src/bot.ts index 7830628..b6a0131 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -22,11 +22,11 @@ export class Bot { async canTriggerBot() { this.logger.debug("Evaluating if user can trigger the bot"); - 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; + // if (this.comment.user.id === author) { + // this.logger.debug("Author of comment is also author of PR") + // return true; + // } this.logger.debug("Author of comment is not the author of the PR"); return await this.commentsApi.userBelongsToOrg(this.comment.user.login); diff --git a/src/github/comments.ts b/src/github/comments.ts index 6239e2f..54fdb41 100644 --- a/src/github/comments.ts +++ b/src/github/comments.ts @@ -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 { - const check = await this.api.rest.orgs.listForUser({username, per_page: 100}); + async userBelongsToOrg(username: string): Promise { + // 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);