Skip to content

Commit

Permalink
feat: allow blocking orgs (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt authored Jan 14, 2021
1 parent 1690413 commit ddaccc8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/solidarity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,13 @@ test("update should chunk annotations", async () => {
expect(update.mock.calls[1][0].output.annotations.length).toBe(50);
expect(update.mock.calls[2][0].output.annotations.length).toBe(1);
});

test("solidarity blocks some orgs", async () => {
const env = process.env;
const s = new Solidarity({ name: "foo", id: "bar", payload: payload } as any);
s.config = DEFAULT_CONFIGURATION;
expect(s.isBlockedOwner()).toBeFalsy();
process.env.BLOCKED_ORGS = "jpoehnelt,baz";
expect(s.isBlockedOwner()).toBeTruthy();
process.env = env;
});
12 changes: 12 additions & 0 deletions src/solidarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,23 @@ export class Solidarity {
};
}

isBlockedOwner(): boolean {
return (process.env.BLOCKED_ORGS || "")
.toLowerCase()
.split(",")
.includes(this.owner.toLocaleLowerCase());
}

async run(): Promise<void> {
let conclusion: Conclusion = Conclusion.NEUTRAL;
let output: { title: string; summary: string };

await this.start();

if (this.isBlockedOwner()) {
return this.update("completed", Conclusion.CANCELLED);
}

await this.update("in_progress");

try {
Expand Down

0 comments on commit ddaccc8

Please sign in to comment.