mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix(plex): use server 'address' returned by Plex API (#1379)
This commit is contained in:
@@ -200,9 +200,6 @@ components:
|
||||
message:
|
||||
type: string
|
||||
example: 'OK'
|
||||
host:
|
||||
type: string
|
||||
example: '127-0-0-1.2ab6ce1a093d465e910def96cf4e4799.plex.direct'
|
||||
required:
|
||||
- protocol
|
||||
- address
|
||||
|
@@ -113,7 +113,6 @@ settingsRoutes.post('/plex', async (req, res, next) => {
|
||||
|
||||
settingsRoutes.get('/plex/devices/servers', async (req, res, next) => {
|
||||
const userRepository = getRepository(User);
|
||||
const regexp = /(http(s?):\/\/)(.*)(:[0-9]*)/;
|
||||
try {
|
||||
const admin = await userRepository.findOneOrFail({
|
||||
select: ['id', 'plexToken'],
|
||||
@@ -126,18 +125,15 @@ settingsRoutes.get('/plex/devices/servers', async (req, res, next) => {
|
||||
return device.provides.includes('server') && device.owned;
|
||||
});
|
||||
const settings = getSettings();
|
||||
|
||||
if (devices) {
|
||||
await Promise.all(
|
||||
devices.map(async (device) => {
|
||||
await Promise.all(
|
||||
device.connection.map(async (connection) => {
|
||||
connection.host = connection.uri.replace(regexp, '$3');
|
||||
let msg:
|
||||
| { status: number; message: string }
|
||||
| undefined = undefined;
|
||||
const plexDeviceSettings = {
|
||||
...settings.plex,
|
||||
ip: connection.host,
|
||||
ip: connection.address,
|
||||
port: connection.port,
|
||||
useSsl: connection.protocol === 'https' ? true : false,
|
||||
};
|
||||
@@ -146,20 +142,15 @@ settingsRoutes.get('/plex/devices/servers', async (req, res, next) => {
|
||||
plexSettings: plexDeviceSettings,
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
try {
|
||||
await plexClient.getStatus();
|
||||
msg = {
|
||||
status: 200,
|
||||
message: 'OK',
|
||||
};
|
||||
connection.status = 200;
|
||||
connection.message = 'OK';
|
||||
} catch (e) {
|
||||
msg = {
|
||||
status: 500,
|
||||
message: e.message,
|
||||
};
|
||||
connection.status = 500;
|
||||
connection.message = e.message;
|
||||
}
|
||||
connection.status = msg?.status;
|
||||
connection.message = msg?.message;
|
||||
})
|
||||
);
|
||||
})
|
||||
|
Reference in New Issue
Block a user