From add5219d34a0f18cbe334664abc81c4b5c66913a Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Wed, 28 Jun 2023 13:58:38 -0400 Subject: [PATCH] fix: live photos not playing in shared links/albums (#3008) --- .../infra/repositories/access.repository.ts | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/server/src/infra/repositories/access.repository.ts b/server/src/infra/repositories/access.repository.ts index 11f520993c..d1d986e720 100644 --- a/server/src/infra/repositories/access.repository.ts +++ b/server/src/infra/repositories/access.repository.ts @@ -40,6 +40,21 @@ export class AccessRepository implements IAccessRepository { id: assetId, }, }, + // still part of a live photo is in an album + { + ownerId: userId, + assets: { + livePhotoVideoId: assetId, + }, + }, + { + sharedUsers: { + id: userId, + }, + assets: { + livePhotoVideoId: assetId, + }, + }, ], }); }, @@ -75,10 +90,9 @@ export class AccessRepository implements IAccessRepository { }, hasSharedLinkAccess: async (sharedLinkId: string, assetId: string): Promise => { - return ( - // album asset - (await this.sharedLinkRepository.exist({ - where: { + return this.sharedLinkRepository.exist({ + where: [ + { id: sharedLinkId, album: { assets: { @@ -86,17 +100,29 @@ export class AccessRepository implements IAccessRepository { }, }, }, - })) || - // individual asset - (await this.sharedLinkRepository.exist({ - where: { + { id: sharedLinkId, assets: { id: assetId, }, }, - })) - ); + // still part of a live photo is in a shared link + { + id: sharedLinkId, + album: { + assets: { + livePhotoVideoId: assetId, + }, + }, + }, + { + id: sharedLinkId, + assets: { + livePhotoVideoId: assetId, + }, + }, + ], + }); }, };