Browse Source

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 year ago
parent
commit
26bc889f8d
1 changed files with 4 additions and 1 deletions
  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[]> {
   getByAssetId(ownerId: string, assetId: string): Promise<AlbumEntity[]> {
     return this.repository.find({
     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 },
       relations: { owner: true, sharedUsers: true },
       order: { createdAt: 'DESC' },
       order: { createdAt: 'DESC' },
     });
     });