mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-03-02 04:00:11 +00:00
refactor(server): shared link asset access check (#2680)
This commit is contained in:
@@ -3,4 +3,5 @@ export const IAccessRepository = 'IAccessRepository';
|
||||
export interface IAccessRepository {
|
||||
hasPartnerAccess(userId: string, partnerId: string): Promise<boolean>;
|
||||
hasPartnerAssetAccess(userId: string, assetId: string): Promise<boolean>;
|
||||
hasSharedLinkAssetAccess(userId: string, assetId: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
@@ -47,10 +47,6 @@ export class SharedLinkCore {
|
||||
return this.repository.update({ ...link, assets: newAssets });
|
||||
}
|
||||
|
||||
async hasAssetAccess(id: string, assetId: string): Promise<boolean> {
|
||||
return this.repository.hasAssetAccess(id, assetId);
|
||||
}
|
||||
|
||||
checkDownloadAccess(user: AuthUserDto) {
|
||||
if (user.isPublicUser && !user.isAllowDownload) {
|
||||
throw new ForbiddenException();
|
||||
|
||||
@@ -9,5 +9,4 @@ export interface ISharedLinkRepository {
|
||||
create(entity: Omit<SharedLinkEntity, 'id' | 'user'>): Promise<SharedLinkEntity>;
|
||||
update(entity: Partial<SharedLinkEntity>): Promise<SharedLinkEntity>;
|
||||
remove(entity: SharedLinkEntity): Promise<void>;
|
||||
hasAssetAccess(id: string, assetId: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ export const newAccessRepositoryMock = (): jest.Mocked<IAccessRepository> => {
|
||||
return {
|
||||
hasPartnerAccess: jest.fn(),
|
||||
hasPartnerAssetAccess: jest.fn(),
|
||||
hasSharedLinkAssetAccess: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,6 +8,5 @@ export const newSharedLinkRepositoryMock = (): jest.Mocked<ISharedLinkRepository
|
||||
create: jest.fn(),
|
||||
remove: jest.fn(),
|
||||
update: jest.fn(),
|
||||
hasAssetAccess: jest.fn(),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user