refactor(server): download endpoints (#6653)

* refactor(server): download controller

* chore: open api

* chore: fix mobile references
This commit is contained in:
Jason Rasmussen 2024-01-26 09:19:13 -05:00 committed by GitHub
parent de47a6a330
commit 7ea55c7236
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 1420 additions and 388 deletions

View file

@ -13,6 +13,7 @@ import {
DeviceIdDto,
DownloadInfoDto,
DownloadResponseDto,
DownloadService,
MapMarkerDto,
MapMarkerResponseDto,
MemoryLaneDto,
@ -65,7 +66,10 @@ export class AssetsController {
@Authenticated()
@UseValidation()
export class AssetController {
constructor(private service: AssetService) {}
constructor(
private service: AssetService,
private downloadService: DownloadService,
) {}
@Get('map-marker')
getMapMarkers(@Auth() auth: AuthDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
@ -82,31 +86,40 @@ export class AssetController {
return this.service.getRandom(auth, dto.count ?? 1);
}
/**
* @deprecated use `/download/info`
*/
@SharedLinkRoute()
@Post('download/info')
getDownloadInfo(@Auth() auth: AuthDto, @Body() dto: DownloadInfoDto): Promise<DownloadResponseDto> {
return this.service.getDownloadInfo(auth, dto);
getDownloadInfoOld(@Auth() auth: AuthDto, @Body() dto: DownloadInfoDto): Promise<DownloadResponseDto> {
return this.downloadService.getDownloadInfo(auth, dto);
}
/**
* @deprecated use `/download/archive`
*/
@SharedLinkRoute()
@Post('download/archive')
@HttpCode(HttpStatus.OK)
@FileResponse()
downloadArchive(@Auth() auth: AuthDto, @Body() dto: AssetIdsDto): Promise<StreamableFile> {
return this.service.downloadArchive(auth, dto).then(asStreamableFile);
downloadArchiveOld(@Auth() auth: AuthDto, @Body() dto: AssetIdsDto): Promise<StreamableFile> {
return this.downloadService.downloadArchive(auth, dto).then(asStreamableFile);
}
/**
* @deprecated use `/download/:id`
*/
@SharedLinkRoute()
@Post('download/:id')
@HttpCode(HttpStatus.OK)
@FileResponse()
async downloadFile(
async downloadFileOld(
@Res() res: Response,
@Next() next: NextFunction,
@Auth() auth: AuthDto,
@Param() { id }: UUIDParamDto,
) {
await sendFile(res, next, () => this.service.downloadFile(auth, id));
await sendFile(res, next, () => this.downloadService.downloadFile(auth, id));
}
/**