mirror of
https://github.com/immich-app/immich.git
synced 2025-06-03 21:57:07 -04:00
* refactor(server): shared links * chore: tests * fix: bugs and tests * fix: missed one expired at * fix: standardize file upload checks * test: lower flutter version Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Patch, ValidationPipe } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { GetAuthUser } from '../decorators/auth-user.decorator';
|
|
import { Authenticated } from '../decorators/authenticated.decorator';
|
|
import { AuthUserDto, EditSharedLinkDto, SharedLinkResponseDto, ShareService } from '@app/domain';
|
|
|
|
@ApiTags('share')
|
|
@Controller('share')
|
|
export class ShareController {
|
|
constructor(private readonly shareService: ShareService) {}
|
|
@Authenticated()
|
|
@Get()
|
|
getAllSharedLinks(@GetAuthUser() authUser: AuthUserDto): Promise<SharedLinkResponseDto[]> {
|
|
return this.shareService.getAll(authUser);
|
|
}
|
|
|
|
@Authenticated({ isShared: true })
|
|
@Get('me')
|
|
getMySharedLink(@GetAuthUser() authUser: AuthUserDto): Promise<SharedLinkResponseDto> {
|
|
return this.shareService.getMine(authUser);
|
|
}
|
|
|
|
@Authenticated()
|
|
@Get(':id')
|
|
getSharedLinkById(@GetAuthUser() authUser: AuthUserDto, @Param('id') id: string): Promise<SharedLinkResponseDto> {
|
|
return this.shareService.getById(authUser, id, true);
|
|
}
|
|
|
|
@Authenticated()
|
|
@Delete(':id')
|
|
removeSharedLink(@GetAuthUser() authUser: AuthUserDto, @Param('id') id: string): Promise<void> {
|
|
return this.shareService.remove(authUser, id);
|
|
}
|
|
|
|
@Authenticated()
|
|
@Patch(':id')
|
|
editSharedLink(
|
|
@GetAuthUser() authUser: AuthUserDto,
|
|
@Param('id') id: string,
|
|
@Body(new ValidationPipe()) dto: EditSharedLinkDto,
|
|
): Promise<SharedLinkResponseDto> {
|
|
return this.shareService.edit(authUser, id, dto);
|
|
}
|
|
}
|