|
@@ -97,6 +97,7 @@ export class AssetController {
|
|
@Query(new ValidationPipe({ transform: true })) query: ServeFileDto,
|
|
@Query(new ValidationPipe({ transform: true })) query: ServeFileDto,
|
|
@Param('assetId') assetId: string,
|
|
@Param('assetId') assetId: string,
|
|
): Promise<any> {
|
|
): Promise<any> {
|
|
|
|
+ this.assetService.checkDownloadAccess(authUser);
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
return this.assetService.downloadFile(query, assetId, res);
|
|
return this.assetService.downloadFile(query, assetId, res);
|
|
}
|
|
}
|
|
@@ -108,6 +109,7 @@ export class AssetController {
|
|
@Response({ passthrough: true }) res: Res,
|
|
@Response({ passthrough: true }) res: Res,
|
|
@Body(new ValidationPipe()) dto: DownloadFilesDto,
|
|
@Body(new ValidationPipe()) dto: DownloadFilesDto,
|
|
): Promise<any> {
|
|
): Promise<any> {
|
|
|
|
+ this.assetService.checkDownloadAccess(authUser);
|
|
await this.assetService.checkAssetsAccess(authUser, [...dto.assetIds]);
|
|
await this.assetService.checkAssetsAccess(authUser, [...dto.assetIds]);
|
|
const { stream, fileName, fileSize, fileCount, complete } = await this.assetService.downloadFiles(dto);
|
|
const { stream, fileName, fileSize, fileCount, complete } = await this.assetService.downloadFiles(dto);
|
|
res.attachment(fileName);
|
|
res.attachment(fileName);
|
|
@@ -117,6 +119,9 @@ export class AssetController {
|
|
return stream;
|
|
return stream;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Current this is not used in any UI element
|
|
|
|
+ */
|
|
@Authenticated({ isShared: true })
|
|
@Authenticated({ isShared: true })
|
|
@Get('/download-library')
|
|
@Get('/download-library')
|
|
async downloadLibrary(
|
|
async downloadLibrary(
|
|
@@ -124,6 +129,7 @@ export class AssetController {
|
|
@Query(new ValidationPipe({ transform: true })) dto: DownloadDto,
|
|
@Query(new ValidationPipe({ transform: true })) dto: DownloadDto,
|
|
@Response({ passthrough: true }) res: Res,
|
|
@Response({ passthrough: true }) res: Res,
|
|
): Promise<any> {
|
|
): Promise<any> {
|
|
|
|
+ this.assetService.checkDownloadAccess(authUser);
|
|
const { stream, fileName, fileSize, fileCount, complete } = await this.assetService.downloadLibrary(authUser, dto);
|
|
const { stream, fileName, fileSize, fileCount, complete } = await this.assetService.downloadLibrary(authUser, dto);
|
|
res.attachment(fileName);
|
|
res.attachment(fileName);
|
|
res.setHeader(IMMICH_CONTENT_LENGTH_HINT, fileSize);
|
|
res.setHeader(IMMICH_CONTENT_LENGTH_HINT, fileSize);
|
|
@@ -143,7 +149,7 @@ export class AssetController {
|
|
@Param('assetId') assetId: string,
|
|
@Param('assetId') assetId: string,
|
|
): Promise<any> {
|
|
): Promise<any> {
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
- return this.assetService.serveFile(assetId, query, res, headers);
|
|
|
|
|
|
+ return this.assetService.serveFile(authUser, assetId, query, res, headers);
|
|
}
|
|
}
|
|
|
|
|
|
@Authenticated({ isShared: true })
|
|
@Authenticated({ isShared: true })
|
|
@@ -246,7 +252,7 @@ export class AssetController {
|
|
@Param('assetId') assetId: string,
|
|
@Param('assetId') assetId: string,
|
|
): Promise<AssetResponseDto> {
|
|
): Promise<AssetResponseDto> {
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
await this.assetService.checkAssetsAccess(authUser, [assetId]);
|
|
- return await this.assetService.getAssetById(assetId);
|
|
|
|
|
|
+ return await this.assetService.getAssetById(authUser, assetId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -274,14 +280,14 @@ export class AssetController {
|
|
const deleteAssetList: AssetResponseDto[] = [];
|
|
const deleteAssetList: AssetResponseDto[] = [];
|
|
|
|
|
|
for (const id of assetIds.ids) {
|
|
for (const id of assetIds.ids) {
|
|
- const assets = await this.assetService.getAssetById(id);
|
|
|
|
|
|
+ const assets = await this.assetService.getAssetById(authUser, id);
|
|
if (!assets) {
|
|
if (!assets) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
deleteAssetList.push(assets);
|
|
deleteAssetList.push(assets);
|
|
|
|
|
|
if (assets.livePhotoVideoId) {
|
|
if (assets.livePhotoVideoId) {
|
|
- const livePhotoVideo = await this.assetService.getAssetById(assets.livePhotoVideoId);
|
|
|
|
|
|
+ const livePhotoVideo = await this.assetService.getAssetById(authUser, assets.livePhotoVideoId);
|
|
if (livePhotoVideo) {
|
|
if (livePhotoVideo) {
|
|
deleteAssetList.push(livePhotoVideo);
|
|
deleteAssetList.push(livePhotoVideo);
|
|
assetIds.ids = [...assetIds.ids, livePhotoVideo.id];
|
|
assetIds.ids = [...assetIds.ids, livePhotoVideo.id];
|