Browse Source

fix: album performances (#5224)

* fix: album performances

* fix: tests
martin 1 year ago
parent
commit
c438e17954

+ 2 - 1
server/src/domain/album/album.service.ts

@@ -81,7 +81,8 @@ export class AlbumService {
   async get(authUser: AuthUserDto, id: string, dto: AlbumInfoDto): Promise<AlbumResponseDto> {
   async get(authUser: AuthUserDto, id: string, dto: AlbumInfoDto): Promise<AlbumResponseDto> {
     await this.access.requirePermission(authUser, Permission.ALBUM_READ, id);
     await this.access.requirePermission(authUser, Permission.ALBUM_READ, id);
     await this.albumRepository.updateThumbnails();
     await this.albumRepository.updateThumbnails();
-    return mapAlbum(await this.findOrFail(id, { withAssets: true }), !dto.withoutAssets);
+    const withAssets = dto.withoutAssets === undefined ? true : !dto.withoutAssets;
+    return mapAlbum(await this.findOrFail(id, { withAssets }), !dto.withoutAssets);
   }
   }
 
 
   async create(authUser: AuthUserDto, dto: CreateAlbumDto): Promise<AlbumResponseDto> {
   async create(authUser: AuthUserDto, dto: CreateAlbumDto): Promise<AlbumResponseDto> {

+ 4 - 0
server/src/infra/repositories/album.repository.ts

@@ -56,6 +56,7 @@ export class AlbumRepository implements IAlbumRepository {
       ],
       ],
       relations: { owner: true, sharedUsers: true },
       relations: { owner: true, sharedUsers: true },
       order: { createdAt: 'DESC' },
       order: { createdAt: 'DESC' },
+      relationLoadStrategy: 'query',
     });
     });
   }
   }
 
 
@@ -91,6 +92,7 @@ export class AlbumRepository implements IAlbumRepository {
       relations: { sharedUsers: true, sharedLinks: true, owner: true },
       relations: { sharedUsers: true, sharedLinks: true, owner: true },
       where: { ownerId },
       where: { ownerId },
       order: { createdAt: 'DESC' },
       order: { createdAt: 'DESC' },
+      relationLoadStrategy: 'query',
     });
     });
   }
   }
 
 
@@ -106,6 +108,7 @@ export class AlbumRepository implements IAlbumRepository {
         { ownerId, sharedUsers: { id: Not(IsNull()) } },
         { ownerId, sharedUsers: { id: Not(IsNull()) } },
       ],
       ],
       order: { createdAt: 'DESC' },
       order: { createdAt: 'DESC' },
+      relationLoadStrategy: 'query',
     });
     });
   }
   }
 
 
@@ -117,6 +120,7 @@ export class AlbumRepository implements IAlbumRepository {
       relations: { sharedUsers: true, sharedLinks: true, owner: true },
       relations: { sharedUsers: true, sharedLinks: true, owner: true },
       where: { ownerId, sharedUsers: { id: IsNull() }, sharedLinks: { id: IsNull() } },
       where: { ownerId, sharedUsers: { id: IsNull() }, sharedLinks: { id: IsNull() } },
       order: { createdAt: 'DESC' },
       order: { createdAt: 'DESC' },
+      relationLoadStrategy: 'query',
     });
     });
   }
   }