🐛 Fix pull request issues

This commit is contained in:
Meier Lukas
2023-06-10 19:04:54 +02:00
parent d704dfa8b6
commit c1658d68e1
16 changed files with 115 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
import { Client } from 'sabnzbd-api';
import { getConfig } from '../../../../tools/config/getConfig';
import { NzbgetClient } from '../../../../server/api/routers/usenet/nzbget/nzbget-client';
import { findAppProperty } from '~/tools/client/app-properties';
dayjs.extend(duration);
@@ -31,8 +32,8 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
const options = {
host: url.hostname,
port: url.port || (url.protocol === 'https:' ? '443' : '80'),
login: app.integration.properties.find((x) => x.field === 'username')?.value ?? undefined,
hash: app.integration.properties.find((x) => x.field === 'password')?.value ?? undefined,
login: findAppProperty(app, 'username'),
hash: findAppProperty(app, 'password'),
};
const nzbGet = NzbgetClient(options);
@@ -49,7 +50,7 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
break;
}
case 'sabnzbd': {
const apiKey = app.integration.properties.find((x) => x.field === 'apiKey')?.value;
const apiKey = findAppProperty(app, 'apiKey');
if (!apiKey) {
throw new Error(`API Key for app "${app.name}" is missing`);
}