소스 검색

feat(server): include shared albums in getByAssetId (#3978)

This commit changes the album.getByAssetId API to also consider
albums that have been shared with the current user.
This way when the user is browing their timeline and clicks to show
the asset details they will see if the asset appears in not only their
own albums but also albums shared with them.
Maarten Rijke 1 년 전
부모
커밋
26bc889f8d
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      server/src/infra/repositories/album.repository.ts

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

@@ -50,7 +50,10 @@ export class AlbumRepository implements IAlbumRepository {
 
   getByAssetId(ownerId: string, assetId: string): Promise<AlbumEntity[]> {
     return this.repository.find({
-      where: { ownerId, assets: { id: assetId } },
+      where: [
+        { ownerId, assets: { id: assetId } },
+        { sharedUsers: { id: ownerId }, assets: { id: assetId } },
+      ],
       relations: { owner: true, sharedUsers: true },
       order: { createdAt: 'DESC' },
     });