From f512f55782297afd7f07b1f7a251651a4a6d4f77 Mon Sep 17 00:00:00 2001 From: FoxxMD Date: Mon, 22 Jan 2024 13:21:00 -0500 Subject: [PATCH] feat(deezer): Fix credentials check during build data stage --- src/backend/sources/DeezerSource.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backend/sources/DeezerSource.ts b/src/backend/sources/DeezerSource.ts index 4b2601ea..201c091a 100644 --- a/src/backend/sources/DeezerSource.ts +++ b/src/backend/sources/DeezerSource.ts @@ -34,6 +34,7 @@ export default class DeezerSource extends AbstractSource { data: { interval = 60, redirectUri, + ...rest } = {}, } = config; @@ -41,7 +42,13 @@ export default class DeezerSource extends AbstractSource { 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`; @@ -88,7 +95,11 @@ export default class DeezerSource extends AbstractSource { protected async doBuildInitData(): Promise { 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}); }