Release v2.10.6
This commit is contained in:
@@ -36,22 +36,6 @@ function normalizeBaseUrl(value) {
|
||||
return String(value || '').trim().replace(/\/$/, '');
|
||||
}
|
||||
|
||||
function appendPlayerDeviceIdToUrl(baseUrl, playerIdentifier) {
|
||||
const targetBaseUrl = normalizeBaseUrl(baseUrl);
|
||||
const deviceId = String(playerIdentifier || '').trim();
|
||||
if (!targetBaseUrl || !deviceId) {
|
||||
return targetBaseUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
const url = new URL(targetBaseUrl);
|
||||
url.searchParams.set('deviceId', deviceId);
|
||||
return url.toString().replace(/\/$/, '');
|
||||
} catch (_error) {
|
||||
return targetBaseUrl;
|
||||
}
|
||||
}
|
||||
|
||||
function normalizePlayerRowBaseUrl(player) {
|
||||
return normalizeBaseUrl(player && player.internal_base_url);
|
||||
}
|
||||
@@ -68,6 +52,7 @@ function createUploadSyncService(options) {
|
||||
const pool = options && options.pool;
|
||||
const common = options && options.common;
|
||||
const configuredPlayerInternalBaseUrl = String(options && options.playerInternalBaseUrl || '').replace(/\/$/, '');
|
||||
const configuredBridgeInternalBaseUrl = String(options && options.bridgeInternalBaseUrl || '').trim().replace(/\/$/, '');
|
||||
const playerSnapshotCache = options && options.playerSnapshotCache;
|
||||
const notifyPlayerScreens = options && options.notifyPlayerScreens;
|
||||
const backgroundTaskQueue = options && options.backgroundTaskQueue;
|
||||
@@ -545,6 +530,9 @@ function createUploadSyncService(options) {
|
||||
}
|
||||
|
||||
const playerMetadata = await getPlayerTaskMetadata(preferredPlayerIdentifier, targetBaseUrl);
|
||||
const mediaBaseUrl = playerMetadata && playerMetadata.playerIdentifier && !isLocalLikeBaseUrl(targetBaseUrl) && configuredBridgeInternalBaseUrl
|
||||
? configuredBridgeInternalBaseUrl
|
||||
: targetBaseUrl;
|
||||
const relativePath = getUploadRelativePath(uploadPath);
|
||||
const sourcePath = resolveUploadFilePath(localUploadDir, uploadPath);
|
||||
if (!relativePath || !sourcePath) {
|
||||
@@ -566,11 +554,13 @@ function createUploadSyncService(options) {
|
||||
pathname: `/api/media/${encodeURIComponent(relativePath)}`,
|
||||
body: fileBuffer
|
||||
});
|
||||
const mediaUploadUrl = appendPlayerDeviceIdToUrl(`${targetBaseUrl}/api/media/${encodeURIComponent(relativePath)}`, playerMetadata && playerMetadata.playerIdentifier);
|
||||
const mediaUploadUrl = `${mediaBaseUrl}/api/media/${encodeURIComponent(relativePath)}`;
|
||||
const playerDeviceId = String(playerMetadata && playerMetadata.playerIdentifier || '').trim();
|
||||
const response = await fetch(mediaUploadUrl, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
...(playerDeviceId ? { 'x-pulse-player-device-id': playerDeviceId } : {}),
|
||||
...authHeaders
|
||||
},
|
||||
body: fileBuffer
|
||||
@@ -601,6 +591,9 @@ function createUploadSyncService(options) {
|
||||
}
|
||||
|
||||
const playerMetadata = await getPlayerTaskMetadata(preferredPlayerIdentifier, targetBaseUrl);
|
||||
const mediaBaseUrl = playerMetadata && playerMetadata.playerIdentifier && !isLocalLikeBaseUrl(targetBaseUrl) && configuredBridgeInternalBaseUrl
|
||||
? configuredBridgeInternalBaseUrl
|
||||
: targetBaseUrl;
|
||||
const relativePath = getUploadRelativePath(uploadPath);
|
||||
if (!relativePath) {
|
||||
return false;
|
||||
@@ -610,11 +603,13 @@ function createUploadSyncService(options) {
|
||||
method: 'DELETE',
|
||||
pathname: `/api/media/${encodeURIComponent(relativePath)}`
|
||||
});
|
||||
const mediaDeleteUrl = appendPlayerDeviceIdToUrl(`${targetBaseUrl}/api/media/${encodeURIComponent(relativePath)}`, playerMetadata && playerMetadata.playerIdentifier);
|
||||
const mediaDeleteUrl = `${mediaBaseUrl}/api/media/${encodeURIComponent(relativePath)}`;
|
||||
const playerDeviceId = String(playerMetadata && playerMetadata.playerIdentifier || '').trim();
|
||||
const response = await fetch(mediaDeleteUrl, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
...(playerDeviceId ? { 'x-pulse-player-device-id': playerDeviceId } : {}),
|
||||
...authHeaders
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user