🐛 Fix issue with api endpoints caused by new integration format

This commit is contained in:
Meierschlumpf
2022-12-11 19:33:54 +01:00
parent ed64d138c5
commit 53a86e2bbc
7 changed files with 42 additions and 40 deletions

View File

@@ -31,8 +31,10 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
const options = {
host: url.hostname,
port: url.port,
login: service.integration.properties.username,
hash: service.integration.properties.password,
login:
service.integration.properties.find((x) => x.field === 'username')?.value ?? undefined,
hash:
service.integration.properties.find((x) => x.field === 'password')?.value ?? undefined,
};
const nzbGet = NzbgetClient(options);
@@ -49,13 +51,14 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
break;
}
case 'sabnzbd': {
if (!service.integration.properties.apiKey) {
const apiKey = service.integration.properties.find((x) => x.field === 'apiKey')?.value;
if (!apiKey) {
throw new Error(`API Key for service "${service.name}" is missing`);
}
const { origin } = new URL(service.url);
result = await new Client(origin, service.integration.properties.apiKey).queuePause();
result = await new Client(origin, apiKey).queuePause();
break;
}
default: