Skip to content

Commit

Permalink
feat(deezer): Fix credentials check during build data stage
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxMD committed Jan 22, 2024
1 parent ad6eba5 commit f512f55
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/backend/sources/DeezerSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,21 @@ export default class DeezerSource extends AbstractSource {
data: {
interval = 60,
redirectUri,
...rest
} = {},
} = config;

if (interval < 15) {
this.logger.warn('Interval should be above 30 seconds...😬');
}

this.config.data.interval = interval;
// @ts-ignore
this.config.data = {
...rest,
interval,
redirectUri,
};

this.redirectUri = redirectUri || `${this.localUrl}/deezer/callback`;

this.workingCredsPath = `${this.configDir}/currentCreds-${name}.json`;
Expand Down Expand Up @@ -88,7 +95,11 @@ export default class DeezerSource extends AbstractSource {
protected async doBuildInitData(): Promise<boolean | string> {
try {
const credFile = await readJson(this.workingCredsPath, {throwOnNotFound: false});
this.config.data.accessToken = credFile.accessToken;
if(credFile !== undefined) {
this.config.data.accessToken = credFile.accessToken;
} else {
this.logger.warn(`No Deezer credentials file found at ${this.workingCredsPath}`);
}
} catch (e) {
throw new ErrorWithCause('Current deezer credentials file exists but could not be parsed', {cause: e});
}
Expand Down

0 comments on commit f512f55

Please sign in to comment.