From cc697486fcea51bdcab8439b85b83acb08e4248b Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 21 Nov 2022 20:24:56 -0600 Subject: [PATCH] fix(server): Deleted shared users cause problem with album retrival and creation (#1002) * fix(server): Deleted shared users cause problem with album retrival and creation * Remove dead code --- .../album/response-dto/album-response.dto.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/server/apps/immich/src/api-v1/album/response-dto/album-response.dto.ts b/server/apps/immich/src/api-v1/album/response-dto/album-response.dto.ts index dde9998e3e..71d4475430 100644 --- a/server/apps/immich/src/api-v1/album/response-dto/album-response.dto.ts +++ b/server/apps/immich/src/api-v1/album/response-dto/album-response.dto.ts @@ -18,7 +18,14 @@ export class AlbumResponseDto { } export function mapAlbum(entity: AlbumEntity): AlbumResponseDto { - const sharedUsers = entity.sharedUsers?.map((userAlbum) => mapUser(userAlbum.userInfo)) || []; + const sharedUsers: UserResponseDto[] = []; + + entity.sharedUsers?.forEach((userAlbum) => { + if (userAlbum.userInfo) { + const user = mapUser(userAlbum.userInfo); + sharedUsers.push(user); + } + }); return { albumName: entity.albumName, albumThumbnailAssetId: entity.albumThumbnailAssetId, @@ -33,7 +40,14 @@ export function mapAlbum(entity: AlbumEntity): AlbumResponseDto { } export function mapAlbumExcludeAssetInfo(entity: AlbumEntity): AlbumResponseDto { - const sharedUsers = entity.sharedUsers?.map((userAlbum) => mapUser(userAlbum.userInfo)) || []; + const sharedUsers: UserResponseDto[] = []; + + entity.sharedUsers?.forEach((userAlbum) => { + if (userAlbum.userInfo) { + const user = mapUser(userAlbum.userInfo); + sharedUsers.push(user); + } + }); return { albumName: entity.albumName, albumThumbnailAssetId: entity.albumThumbnailAssetId,