From c6a04c2ebddc9df27da4e01c9e8b5d84c135e712 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Fri, 21 Apr 2023 10:27:57 +0100 Subject: [PATCH] Fix case where GitHub repos aren't connectable if the GitHub App was manually approved (#718) * Fix GitHub connections failing if the installation cache is stale * changelog --- changelog.d/718.bugfix | 1 + src/Connections/GithubRepo.ts | 28 ++++++++++++++++++++++------ src/Github/GrantChecker.ts | 5 ++--- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 changelog.d/718.bugfix diff --git a/changelog.d/718.bugfix b/changelog.d/718.bugfix new file mode 100644 index 00000000..de97bd20 --- /dev/null +++ b/changelog.d/718.bugfix @@ -0,0 +1 @@ +Fix cases of GitHub repos not being bridgable if the GitHub App had to be manually approved. diff --git a/src/Connections/GithubRepo.ts b/src/Connections/GithubRepo.ts index 698c8512..f762cb1c 100644 --- a/src/Connections/GithubRepo.ts +++ b/src/Connections/GithubRepo.ts @@ -383,7 +383,7 @@ export class GitHubRepoConnection extends CommandConnection, timeout: NodeJS.Timeout}>(); - private readonly grantChecker = new GitHubGrantChecker(this.as, this.githubInstance, this.tokenStore); + private readonly grantChecker = new GitHubGrantChecker(this.as, this.tokenStore); constructor( roomId: string, diff --git a/src/Github/GrantChecker.ts b/src/Github/GrantChecker.ts index e3aa9ace..a1497f30 100644 --- a/src/Github/GrantChecker.ts +++ b/src/Github/GrantChecker.ts @@ -2,7 +2,6 @@ import { Appservice } from "matrix-bot-sdk"; import { GitHubRepoConnection } from "../Connections"; import { GrantChecker } from "../grants/GrantCheck"; import { UserTokenStore } from "../UserTokenStore"; -import { GithubInstance } from "./GithubInstance"; import { Logger } from 'matrix-appservice-bridge'; const log = new Logger('GitHubGrantChecker'); @@ -14,7 +13,7 @@ interface GitHubGrantConnectionId { export class GitHubGrantChecker extends GrantChecker { - constructor(private readonly as: Appservice, private readonly github: GithubInstance, private readonly tokenStore: UserTokenStore) { + constructor(private readonly as: Appservice, private readonly tokenStore: UserTokenStore) { super(as.botIntent, "github") } @@ -29,7 +28,7 @@ export class GitHubGrantChecker extends GrantChecker { return true; } try { - await GitHubRepoConnection.assertUserHasAccessToRepo(sender, connectionId.org, connectionId.repo, this.github, this.tokenStore); + await GitHubRepoConnection.assertUserHasAccessToRepo(sender, connectionId.org, connectionId.repo, this.tokenStore); return true; } catch (ex) { log.info(`Tried to check fallback for ${roomId}: ${sender} does not have access to ${connectionId.org}/${connectionId.repo}`, ex);