Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 26, 2023
2 parents 6df9e55 + 7ebb845 commit 0a26d85
Showing 1 changed file with 18 additions and 3 deletions.
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

0 comments on commit 0a26d85

Please sign in to comment.