From c7815c7f587e691d6291bd50d87d4e75bc6bb828 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 28 Oct 2022 11:36:49 -0700 Subject: [PATCH] Fix adding photos to shared album --- src/services/DavRequests.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/services/DavRequests.ts b/src/services/DavRequests.ts index f43094c1..a01e09e7 100644 --- a/src/services/DavRequests.ts +++ b/src/services/DavRequests.ts @@ -556,6 +556,19 @@ export async function* removeFaceImages(user: string, name: string, fileIds: num yield* runInParallel(calls, 10); } +/** + * Get DAV path for album + */ +export function getAlbumPath(user: string, name: string) { + // Folder in the dav collection for user + const cuid = getCurrentUser().uid; + if (user === cuid) { + return `/photos/${cuid}/albums/${name}`; + } else { + return `/photos/${cuid}/sharedalbums/${name} (${user})`; + } +} + /** * Get list of albums and convert to Days response * @param type Type of albums to get; 1 = personal, 2 = shared, 3 = all @@ -595,12 +608,14 @@ export async function* addToAlbum(user: string, name: string, fileIds: number[]) // Get files data let fileInfos = await getFiles(fileIds.filter(f => f)); + const albumPath = getAlbumPath(user, name); + // Add each file const calls = fileInfos.map((f) => async () => { try { await client.copyFile( f.originalFilename, - `/photos/${user}/albums/${name}/${f.basename}`, + `${albumPath}/${f.basename}`, ) return f.fileid; } catch (e) {