From 5ea423072be02beb9489e62c51d8aeb023acbeb1 Mon Sep 17 00:00:00 2001 From: Barnabas Ratki Date: Wed, 3 Jan 2024 20:40:36 +0100 Subject: [PATCH] Small fixes --- server/Database.js | 2 +- server/controllers/LibraryController.js | 4 ++-- server/models/CustomMetadataProvider.js | 2 +- server/providers/CustomProviderAdapter.js | 8 +------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/server/Database.js b/server/Database.js index bbea7352..302170ac 100644 --- a/server/Database.js +++ b/server/Database.js @@ -705,7 +705,7 @@ class Database { * @param {string} providerSlug * @return {boolean} */ - async doesCustomProviderExistBySlug(providerSlug) { + async doesCustomProviderExistWithSlug(providerSlug) { const id = providerSlug.split("custom-")[1] if (!id) { diff --git a/server/controllers/LibraryController.js b/server/controllers/LibraryController.js index 304ca4f0..b1ab572f 100644 --- a/server/controllers/LibraryController.js +++ b/server/controllers/LibraryController.js @@ -53,7 +53,7 @@ class LibraryController { // Validate that the custom provider exists if given any if (newLibraryPayload.provider && newLibraryPayload.provider.startsWith("custom-")) { - await Database.doesCustomProviderExistBySlug(newLibraryPayload.provider) + await Database.doesCustomProviderExistWithSlug(newLibraryPayload.provider) } const library = new Library() @@ -182,7 +182,7 @@ class LibraryController { // Validate that the custom provider exists if given any if (req.body.provider && req.body.provider.startsWith("custom-")) { - await Database.doesCustomProviderExistBySlug(req.body.provider) + await Database.doesCustomProviderExistWithSlug(req.body.provider) } const hasUpdates = library.update(req.body) diff --git a/server/models/CustomMetadataProvider.js b/server/models/CustomMetadataProvider.js index 4f2488d2..9bc175c4 100644 --- a/server/models/CustomMetadataProvider.js +++ b/server/models/CustomMetadataProvider.js @@ -27,7 +27,7 @@ class CustomMetadataProvider extends Model { } static findByPk(id) { - this.findOne({ + return this.findOne({ where: { id, } diff --git a/server/providers/CustomProviderAdapter.js b/server/providers/CustomProviderAdapter.js index 1bf5a5ee..d5f64291 100644 --- a/server/providers/CustomProviderAdapter.js +++ b/server/providers/CustomProviderAdapter.js @@ -8,13 +8,7 @@ class CustomProviderAdapter { async search(title, author, providerSlug) { const providerId = providerSlug.split("custom-")[1] - - console.log(providerId) - const provider = await Database.customMetadataProviderModel.findOne({ - where: { - id: providerId, - } - }); + const provider = await Database.customMetadataProviderModel.findByPk(providerId); if (!provider) { throw new Error("Custom provider not found for the given id");