0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-03-11 02:23:09 -05:00

hotfix(server): getAlbumByAssetId alters album content (#1828)

This commit is contained in:
Alex 2023-02-21 21:53:00 -06:00 committed by GitHub
parent 9ebed3c1b4
commit 3102c3128f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
import { AlbumEntity, AssetEntity, UserEntity } from '@app/infra';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, Not, IsNull, FindManyOptions } from 'typeorm';
import { Repository, Not, IsNull, FindManyOptions, In } from 'typeorm';
import { AddAssetsDto } from './dto/add-assets.dto';
import { AddUsersDto } from './dto/add-users.dto';
import { CreateAlbumDto } from './dto/create-album.dto';
@ -121,12 +121,12 @@ export class AlbumRepository implements IAlbumRepository {
async getListByAssetId(userId: string, assetId: string): Promise<AlbumEntity[]> {
const albums = await this.albumRepository.find({
where: { ownerId: userId, assets: { id: assetId } },
where: { ownerId: userId },
relations: { owner: true, assets: true, sharedUsers: true },
order: { assets: { fileCreatedAt: 'ASC' } },
});
return albums;
return albums.filter((album) => album.assets.some((asset) => asset.id === assetId));
}
async get(albumId: string): Promise<AlbumEntity | null> {