Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unauth GitHub api #1221

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/app/core/services/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,29 @@ export class GithubService {
);
}

private fetchSettingsFromRawUrl(): Observable<SessionData> {
return from(fetch(getSettingsUrl(MOD_ORG, DATA_REPO))).pipe(
mergeMap((res) => res.json()),
catchError((err) => throwError('Failed to fetch settings file.'))
);
}

/**
* Fetches the data file that is regulates session information.
* @return Observable<SessionData> representing session information.
*/
fetchSettingsFile(): Observable<SessionData> {
return from(fetch(getSettingsUrl(MOD_ORG, DATA_REPO))).pipe(
mergeMap((res) => res.json()),
catchError((err) => throwError('Failed to fetch settings file.'))
return from(
octokit.repos.getContents({ owner: MOD_ORG, repo: DATA_REPO, path: 'settings.json', headers: GithubService.IF_NONE_MATCH_EMPTY })
).pipe(
map((rawData) => JSON.parse(atob(rawData['data']['content']))),
catchError((err) => {
this.logger.error(
'GithubService: Failed to fetch settings file via REST API. Trying to fetch using raw.githubusercontent.com: ',
err
);
return this.fetchSettingsFromRawUrl();
})
);
}

Expand Down
Loading