Skip to content

Commit

Permalink
chore: mark if project has remote access
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Aug 23, 2024
1 parent 615787e commit 2c13baf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion apps/backend/src/api/handlers/getAuthProject.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { invariant } from "@argos/util/invariant";

import { GithubRepository } from "@/database/models/GithubRepository.js";
import { repoAuth } from "@/web/middlewares/repoAuth.js";
import { boom } from "@/web/util.js";

Expand All @@ -9,11 +12,26 @@ export const getAuthProject: CreateAPIHandler = ({ get }) => {
throw boom(401, "Unauthorized");
}

const referenceBranch = await req.authProject.$getReferenceBranch();
const [referenceBranch] = await Promise.all([
req.authProject.$getReferenceBranch(),
req.authProject.$fetchGraph("githubRepository.activeInstallations"),
]);

invariant(req.authProject.githubRepository?.activeInstallations);

const installation = GithubRepository.pickBestInstallation(
req.authProject.githubRepository.activeInstallations,
);

// We have remote content access if the installation is the main app
const hasRemoteContentAcess = Boolean(
installation && installation.app === "main",
);

res.send({
id: req.authProject.id,
defaultBaseBranch: referenceBranch,
hasRemoteContentAcess,
});
});
};
1 change: 1 addition & 0 deletions apps/backend/src/api/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const serverError = createErrorResponse("Server error");
const Project = z.object({
id: z.string(),
defaultBaseBranch: z.string(),
hasRemoteContentAcess: z.boolean(),
});

const Build = z
Expand Down

0 comments on commit 2c13baf

Please sign in to comment.