mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): library service (#8050)
* refactor: library service * chore: open api * fix: checks
This commit is contained in:
parent
761e7fdd2d
commit
40262c30cb
21 changed files with 198 additions and 335 deletions
|
|
@ -33,12 +33,6 @@ export enum Permission {
|
|||
TIMELINE_READ = 'timeline.read',
|
||||
TIMELINE_DOWNLOAD = 'timeline.download',
|
||||
|
||||
LIBRARY_CREATE = 'library.create',
|
||||
LIBRARY_READ = 'library.read',
|
||||
LIBRARY_UPDATE = 'library.update',
|
||||
LIBRARY_DELETE = 'library.delete',
|
||||
LIBRARY_DOWNLOAD = 'library.download',
|
||||
|
||||
PERSON_READ = 'person.read',
|
||||
PERSON_WRITE = 'person.write',
|
||||
PERSON_MERGE = 'person.merge',
|
||||
|
|
@ -261,29 +255,6 @@ export class AccessCore {
|
|||
return ids.has(auth.user.id) ? new Set([auth.user.id]) : new Set();
|
||||
}
|
||||
|
||||
case Permission.LIBRARY_READ: {
|
||||
if (auth.user.isAdmin) {
|
||||
return new Set(ids);
|
||||
}
|
||||
const isOwner = await this.repository.library.checkOwnerAccess(auth.user.id, ids);
|
||||
const isPartner = await this.repository.library.checkPartnerAccess(auth.user.id, setDifference(ids, isOwner));
|
||||
return setUnion(isOwner, isPartner);
|
||||
}
|
||||
|
||||
case Permission.LIBRARY_UPDATE: {
|
||||
if (auth.user.isAdmin) {
|
||||
return new Set(ids);
|
||||
}
|
||||
return await this.repository.library.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.LIBRARY_DELETE: {
|
||||
if (auth.user.isAdmin) {
|
||||
return new Set(ids);
|
||||
}
|
||||
return await this.repository.library.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
||||
case Permission.PERSON_READ: {
|
||||
return await this.repository.person.checkOwnerAccess(auth.user.id, ids);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue