Fix adding photos to shared album

old-stable24^2
Varun Patil 2022-10-28 11:36:49 -07:00
parent d25ae081d5
commit c7815c7f58
1 changed files with 16 additions and 1 deletions

View File

@ -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) {