mirror of
https://github.com/immich-app/immich.git
synced 2025-12-25 01:11:43 +03:00
* refactor: stacks * mobile: get it built * chore: feedback * fix: sync and duplicates * mobile: remove old stack reference * chore: add primary asset id * revert change to asset entity * mobile: refactor mobile api * mobile: sync stack info after creating stack * mobile: update timeline after deleting stack * server: update asset updatedAt when stack is deleted * mobile: simplify action * mobile: rename to match dto property * fix: web test --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, Post, Put, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { AssetResponseDto, MemoryLaneResponseDto } from 'src/dtos/asset-response.dto';
|
|
import {
|
|
AssetBulkDeleteDto,
|
|
AssetBulkUpdateDto,
|
|
AssetJobsDto,
|
|
AssetStatsDto,
|
|
AssetStatsResponseDto,
|
|
DeviceIdDto,
|
|
RandomAssetsDto,
|
|
UpdateAssetDto,
|
|
} from 'src/dtos/asset.dto';
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
import { MemoryLaneDto } from 'src/dtos/search.dto';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { Route } from 'src/middleware/file-upload.interceptor';
|
|
import { AssetService } from 'src/services/asset.service';
|
|
import { UUIDParamDto } from 'src/validation';
|
|
|
|
@ApiTags('Assets')
|
|
@Controller(Route.ASSET)
|
|
export class AssetController {
|
|
constructor(private service: AssetService) {}
|
|
|
|
@Get('memory-lane')
|
|
@Authenticated()
|
|
getMemoryLane(@Auth() auth: AuthDto, @Query() dto: MemoryLaneDto): Promise<MemoryLaneResponseDto[]> {
|
|
return this.service.getMemoryLane(auth, dto);
|
|
}
|
|
|
|
@Get('random')
|
|
@Authenticated()
|
|
getRandom(@Auth() auth: AuthDto, @Query() dto: RandomAssetsDto): Promise<AssetResponseDto[]> {
|
|
return this.service.getRandom(auth, dto.count ?? 1);
|
|
}
|
|
|
|
/**
|
|
* Get all asset of a device that are in the database, ID only.
|
|
*/
|
|
@Get('/device/:deviceId')
|
|
@Authenticated()
|
|
getAllUserAssetsByDeviceId(@Auth() auth: AuthDto, @Param() { deviceId }: DeviceIdDto) {
|
|
return this.service.getUserAssetsByDeviceId(auth, deviceId);
|
|
}
|
|
|
|
@Get('statistics')
|
|
@Authenticated()
|
|
getAssetStatistics(@Auth() auth: AuthDto, @Query() dto: AssetStatsDto): Promise<AssetStatsResponseDto> {
|
|
return this.service.getStatistics(auth, dto);
|
|
}
|
|
|
|
@Post('jobs')
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@Authenticated()
|
|
runAssetJobs(@Auth() auth: AuthDto, @Body() dto: AssetJobsDto): Promise<void> {
|
|
return this.service.run(auth, dto);
|
|
}
|
|
|
|
@Put()
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@Authenticated()
|
|
updateAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkUpdateDto): Promise<void> {
|
|
return this.service.updateAll(auth, dto);
|
|
}
|
|
|
|
@Delete()
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@Authenticated()
|
|
deleteAssets(@Auth() auth: AuthDto, @Body() dto: AssetBulkDeleteDto): Promise<void> {
|
|
return this.service.deleteAll(auth, dto);
|
|
}
|
|
|
|
@Get(':id')
|
|
@Authenticated({ sharedLink: true })
|
|
getAssetInfo(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<AssetResponseDto> {
|
|
return this.service.get(auth, id) as Promise<AssetResponseDto>;
|
|
}
|
|
|
|
@Put(':id')
|
|
@Authenticated()
|
|
updateAsset(
|
|
@Auth() auth: AuthDto,
|
|
@Param() { id }: UUIDParamDto,
|
|
@Body() dto: UpdateAssetDto,
|
|
): Promise<AssetResponseDto> {
|
|
return this.service.update(auth, id, dto);
|
|
}
|
|
}
|