livephoto: allow access for folder shares
parent
6d508890c4
commit
874258dae9
|
@ -95,28 +95,22 @@ class VideoController extends ApiBase
|
|||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @PublicPage
|
||||
*
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* Return the live video part of a live photo
|
||||
*/
|
||||
public function livephoto(
|
||||
string $fileid,
|
||||
string $etag = '',
|
||||
int $fileid,
|
||||
string $liveid = '',
|
||||
string $format = '',
|
||||
string $transcode = ''
|
||||
) {
|
||||
$fileid = (int) $fileid;
|
||||
$files = $this->rootFolder->getById($fileid);
|
||||
if (0 === \count($files)) {
|
||||
$file = $this->getUserFile($fileid);
|
||||
if (null === $file) {
|
||||
return new JSONResponse(['message' => 'File not found'], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
$file = $files[0];
|
||||
|
||||
// Check file etag
|
||||
if ($etag !== $file->getEtag()) {
|
||||
return new JSONResponse(['message' => 'File changed'], Http::STATUS_PRECONDITION_FAILED);
|
||||
}
|
||||
|
||||
// Check file liveid
|
||||
if (!$liveid) {
|
||||
|
|
|
@ -141,20 +141,23 @@ const getPreviewUrl = function (
|
|||
size: number | [number, number]
|
||||
) {
|
||||
const [x, y] = typeof size === "number" ? [size, size] : size;
|
||||
const a = square ? "0" : "1";
|
||||
|
||||
// Get base URL
|
||||
let url = generateUrl(
|
||||
`/apps/memories/api/image/preview/${photo.fileid}?c=${photo.etag}&x=${x}&y=${y}&a=${a}`
|
||||
);
|
||||
const url = generateUrl(`/apps/memories/api/image/preview/${photo.fileid}`);
|
||||
|
||||
// Build query
|
||||
const query = new URLSearchParams();
|
||||
query.set("c", photo.etag);
|
||||
query.set("x", x.toString());
|
||||
query.set("y", y.toString());
|
||||
query.set("a", square ? "0" : "1");
|
||||
|
||||
// Public preview
|
||||
if (vuerouter.currentRoute.name === "folder-share") {
|
||||
const token = vuerouter.currentRoute.params.token;
|
||||
url += `&folder_share=${token}`;
|
||||
query.set("folder_share", vuerouter.currentRoute.params.token);
|
||||
}
|
||||
|
||||
return url;
|
||||
return url + "?" + query.toString();
|
||||
};
|
||||
|
||||
export {
|
||||
|
|
|
@ -241,11 +241,25 @@ export function getFolderRoutePath(basePath: string) {
|
|||
* Get URL to live photo video part
|
||||
*/
|
||||
export function getLivePhotoVideoUrl(p: IPhoto, transcode: boolean) {
|
||||
let url = generateUrl(
|
||||
`/apps/memories/api/video/livephoto/${p.fileid}?etag=${p.etag}&liveid=${p.liveid}`
|
||||
);
|
||||
if (transcode) url += `&transcode=${videoClientIdPersistent}`;
|
||||
return url;
|
||||
// Get base url
|
||||
const url = generateUrl(`/apps/memories/api/video/livephoto/${p.fileid}`);
|
||||
|
||||
// Build query string
|
||||
const query = new URLSearchParams();
|
||||
query.set("etag", p.etag);
|
||||
query.set("liveid", p.liveid);
|
||||
|
||||
// Transcode if allowed
|
||||
if (transcode) {
|
||||
query.set("transcode", videoClientIdPersistent);
|
||||
}
|
||||
|
||||
// Add auth token for public share
|
||||
if (vuerouter.currentRoute.name === "folder-share") {
|
||||
query.set("folder_share", vuerouter.currentRoute.params.token);
|
||||
}
|
||||
|
||||
return url + "?" + query.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue