1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix: user specific fields in asset search (#12125)

This commit is contained in:
Jason Rasmussen 2024-08-29 18:07:45 -04:00 committed by GitHub
parent 715ac4c599
commit c63f63cc15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import { BadRequestException, Inject, Injectable } from '@nestjs/common'; import { BadRequestException, Inject, Injectable } from '@nestjs/common';
import { SystemConfigCore } from 'src/cores/system-config.core'; import { SystemConfigCore } from 'src/cores/system-config.core';
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto'; import { AssetMapOptions, AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto'; import { AuthDto } from 'src/dtos/auth.dto';
import { PersonResponseDto } from 'src/dtos/person.dto'; import { PersonResponseDto } from 'src/dtos/person.dto';
import { import {
@ -92,7 +92,7 @@ export class SearchService {
}, },
); );
return this.mapResponse(items, hasNextPage ? (page + 1).toString() : null); return this.mapResponse(items, hasNextPage ? (page + 1).toString() : null, { auth });
} }
async searchSmart(auth: AuthDto, dto: SmartSearchDto): Promise<SearchResponseDto> { async searchSmart(auth: AuthDto, dto: SmartSearchDto): Promise<SearchResponseDto> {
@ -111,7 +111,7 @@ export class SearchService {
{ ...dto, userIds, embedding }, { ...dto, userIds, embedding },
); );
return this.mapResponse(items, hasNextPage ? (page + 1).toString() : null); return this.mapResponse(items, hasNextPage ? (page + 1).toString() : null, { auth });
} }
async getAssetsByCity(auth: AuthDto): Promise<AssetResponseDto[]> { async getAssetsByCity(auth: AuthDto): Promise<AssetResponseDto[]> {
@ -157,13 +157,13 @@ export class SearchService {
return [auth.user.id, ...partnerIds]; return [auth.user.id, ...partnerIds];
} }
private mapResponse(assets: AssetEntity[], nextPage: string | null): SearchResponseDto { private mapResponse(assets: AssetEntity[], nextPage: string | null, options: AssetMapOptions): SearchResponseDto {
return { return {
albums: { total: 0, count: 0, items: [], facets: [] }, albums: { total: 0, count: 0, items: [], facets: [] },
assets: { assets: {
total: assets.length, total: assets.length,
count: assets.length, count: assets.length,
items: assets.map((asset) => mapAsset(asset)), items: assets.map((asset) => mapAsset(asset, options)),
facets: [], facets: [],
nextPage, nextPage,
}, },