mirror of
https://github.com/immich-app/immich.git
synced 2025-12-24 00:17:48 +09:00
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docker / pre-job (push) Has been cancelled
Docs build / pre-job (push) Has been cancelled
Static Code Analysis / pre-job (push) Has been cancelled
Static Code Analysis / zizmor (push) Has been cancelled
Test / pre-job (push) Has been cancelled
Test / ShellCheck (push) Has been cancelled
Test / OpenAPI Clients (push) Has been cancelled
Test / SQL Schema Checks (push) Has been cancelled
Docker / Re-Tag ML () (push) Has been cancelled
Docker / Re-Tag ML (-armnn) (push) Has been cancelled
Docker / Re-Tag ML (-cuda) (push) Has been cancelled
Docker / Re-Tag ML (-openvino) (push) Has been cancelled
Docker / Re-Tag ML (-rknn) (push) Has been cancelled
Docker / Re-Tag ML (-rocm) (push) Has been cancelled
Docker / Re-Tag Server () (push) Has been cancelled
Docker / Build and Push ML (armnn, linux/arm64, -armnn) (push) Has been cancelled
Docker / Build and Push ML (cpu, ) (push) Has been cancelled
Docker / Build and Push ML (cuda, linux/amd64, -cuda) (push) Has been cancelled
Docker / Build and Push ML (openvino, linux/amd64, -openvino) (push) Has been cancelled
Docker / Build and Push ML (rknn, linux/arm64, -rknn) (push) Has been cancelled
Docker / Build and Push ML (rocm, linux/amd64, {"linux/amd64": "mich"}, -rocm) (push) Has been cancelled
Docker / Build and Push Server (push) Has been cancelled
Docker / Docker Build & Push Server Success (push) Has been cancelled
Docker / Docker Build & Push ML Success (push) Has been cancelled
Docs build / Docs Build (push) Has been cancelled
Static Code Analysis / Run Dart Code Analysis (push) Has been cancelled
Test / Test & Lint Server (push) Has been cancelled
Test / Unit Test CLI (push) Has been cancelled
Test / Unit Test CLI (Windows) (push) Has been cancelled
Test / Lint Web (push) Has been cancelled
Test / Test Web (push) Has been cancelled
Test / Test i18n (push) Has been cancelled
Test / End-to-End Lint (push) Has been cancelled
Test / Medium Tests (Server) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Server & CLI) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-24.04-arm) (push) Has been cancelled
Test / End-to-End Tests (Web) (ubuntu-latest) (push) Has been cancelled
Test / End-to-End Tests Success (push) Has been cancelled
Test / Unit Test Mobile (push) Has been cancelled
Test / Unit Test ML (push) Has been cancelled
Test / .github Files Formatting (push) Has been cancelled
* chore: update response codes * chore: skip problematic test
95 lines
3.3 KiB
TypeScript
95 lines
3.3 KiB
TypeScript
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
|
import { PersonResponseDto } from 'src/dtos/person.dto';
|
|
import {
|
|
LargeAssetSearchDto,
|
|
MetadataSearchDto,
|
|
PlacesResponseDto,
|
|
RandomSearchDto,
|
|
SearchExploreResponseDto,
|
|
SearchPeopleDto,
|
|
SearchPlacesDto,
|
|
SearchResponseDto,
|
|
SearchStatisticsResponseDto,
|
|
SearchSuggestionRequestDto,
|
|
SmartSearchDto,
|
|
StatisticsSearchDto,
|
|
} from 'src/dtos/search.dto';
|
|
import { Permission } from 'src/enum';
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
import { SearchService } from 'src/services/search.service';
|
|
|
|
@ApiTags('Search')
|
|
@Controller('search')
|
|
export class SearchController {
|
|
constructor(private service: SearchService) {}
|
|
|
|
@Post('metadata')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
@HttpCode(HttpStatus.OK)
|
|
searchAssets(@Auth() auth: AuthDto, @Body() dto: MetadataSearchDto): Promise<SearchResponseDto> {
|
|
return this.service.searchMetadata(auth, dto);
|
|
}
|
|
|
|
@Post('statistics')
|
|
@Authenticated({ permission: Permission.AssetStatistics })
|
|
@HttpCode(HttpStatus.OK)
|
|
searchAssetStatistics(@Auth() auth: AuthDto, @Body() dto: StatisticsSearchDto): Promise<SearchStatisticsResponseDto> {
|
|
return this.service.searchStatistics(auth, dto);
|
|
}
|
|
|
|
@Post('random')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
@HttpCode(HttpStatus.OK)
|
|
searchRandom(@Auth() auth: AuthDto, @Body() dto: RandomSearchDto): Promise<AssetResponseDto[]> {
|
|
return this.service.searchRandom(auth, dto);
|
|
}
|
|
|
|
@Post('large-assets')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
@HttpCode(HttpStatus.OK)
|
|
searchLargeAssets(@Auth() auth: AuthDto, @Query() dto: LargeAssetSearchDto): Promise<AssetResponseDto[]> {
|
|
return this.service.searchLargeAssets(auth, dto);
|
|
}
|
|
|
|
@Post('smart')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
@HttpCode(HttpStatus.OK)
|
|
searchSmart(@Auth() auth: AuthDto, @Body() dto: SmartSearchDto): Promise<SearchResponseDto> {
|
|
return this.service.searchSmart(auth, dto);
|
|
}
|
|
|
|
@Get('explore')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
getExploreData(@Auth() auth: AuthDto): Promise<SearchExploreResponseDto[]> {
|
|
return this.service.getExploreData(auth);
|
|
}
|
|
|
|
@Get('person')
|
|
@Authenticated({ permission: Permission.PersonRead })
|
|
searchPerson(@Auth() auth: AuthDto, @Query() dto: SearchPeopleDto): Promise<PersonResponseDto[]> {
|
|
return this.service.searchPerson(auth, dto);
|
|
}
|
|
|
|
@Get('places')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
searchPlaces(@Query() dto: SearchPlacesDto): Promise<PlacesResponseDto[]> {
|
|
return this.service.searchPlaces(dto);
|
|
}
|
|
|
|
@Get('cities')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
getAssetsByCity(@Auth() auth: AuthDto): Promise<AssetResponseDto[]> {
|
|
return this.service.getAssetsByCity(auth);
|
|
}
|
|
|
|
@Get('suggestions')
|
|
@Authenticated({ permission: Permission.AssetRead })
|
|
getSearchSuggestions(@Auth() auth: AuthDto, @Query() dto: SearchSuggestionRequestDto): Promise<string[]> {
|
|
// TODO fix open api generation to indicate that results can be nullable
|
|
return this.service.getSearchSuggestions(auth, dto) as Promise<string[]>;
|
|
}
|
|
}
|