mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-20 00:14:43 +02:00
try to fix repo access
This commit is contained in:
+12
-11
@@ -28,18 +28,19 @@ export async function checkToken(token: string) {
|
||||
export async function getToken(repository: Repository) {
|
||||
const span = trace.getTracer("ano-file").startSpan("GHUtils.getToken");
|
||||
span.setAttribute("repoId", repository.repoId);
|
||||
console.log("getToken", repository.repoId);
|
||||
try {
|
||||
if (repository.model.source.accessToken) {
|
||||
// only check the token if the repo has been visited less than 10 minutes ago
|
||||
if (
|
||||
repository.status == RepositoryStatus.READY &&
|
||||
repository.model.lastView > new Date(Date.now() - 1000 * 60 * 10)
|
||||
) {
|
||||
return repository.model.source.accessToken;
|
||||
} else if (await checkToken(repository.model.source.accessToken)) {
|
||||
return repository.model.source.accessToken;
|
||||
}
|
||||
}
|
||||
// if (repository.model.source.accessToken) {
|
||||
// // only check the token if the repo has been visited less than 10 minutes ago
|
||||
// if (
|
||||
// repository.status == RepositoryStatus.READY &&
|
||||
// repository.model.lastView > new Date(Date.now() - 1000 * 60 * 10)
|
||||
// ) {
|
||||
// return repository.model.source.accessToken;
|
||||
// } else if (await checkToken(repository.model.source.accessToken)) {
|
||||
// return repository.model.source.accessToken;
|
||||
// }
|
||||
// }
|
||||
if (!repository.owner.model.accessTokens?.github) {
|
||||
const query = await UserModel.findById(repository.owner.id, {
|
||||
accessTokens: 1,
|
||||
|
||||
Reference in New Issue
Block a user