fix(jellyfin): ensure deviceID is never empty (#1538)

If the deviceID becomes an empty string, login fails since jellyfin
requires a non-null deviceID. This commit adds a fallback to guarantee
that deviceID is always set, preventing accidental lockout.
This commit is contained in:
fallenbagel
2025-03-28 05:21:47 +08:00
committed by GitHub
parent 0b0b76e58c
commit 7438042757

View File

@@ -110,11 +110,18 @@ class JellyfinAPI extends ExternalAPI {
deviceId?: string | null
) {
const settings = getSettings();
const safeDeviceId =
deviceId && deviceId.length > 0
? deviceId
: Buffer.from(`BOT_jellyseerr_fallback_${Date.now()}`).toString(
'base64'
);
let authHeaderVal: string;
if (authToken) {
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="${getAppVersion()}", Token="${authToken}"`;
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${safeDeviceId}", Version="${getAppVersion()}", Token="${authToken}"`;
} else {
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${deviceId}", Version="${getAppVersion()}"`;
authHeaderVal = `MediaBrowser Client="Jellyseerr", Device="Jellyseerr", DeviceId="${safeDeviceId}", Version="${getAppVersion()}"`;
}
super(