mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 17:25:11 +03:00
fix(server): tighten asset visibility (#18699)
* tighten visibility * update sql * elevated access util function * fix potential sync issue * include in user stats * include hidden assets in size usage * filter visibility in search duplicates query * stack visibility
This commit is contained in:
@@ -304,3 +304,9 @@ const checkOtherAccess = async (access: AccessRepository, request: OtherAccessRe
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const requireElevatedPermission = (auth: AuthDto) => {
|
||||
if (!auth.session?.hasElevatedPermission) {
|
||||
throw new UnauthorizedException('Elevated permission is required');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -153,17 +153,12 @@ export function toJson<DB, TB extends keyof DB & string, T extends TB | Expressi
|
||||
}
|
||||
|
||||
export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_checksum';
|
||||
// TODO come up with a better query that only selects the fields we need
|
||||
|
||||
export function withDefaultVisibility<O>(qb: SelectQueryBuilder<DB, 'assets', O>) {
|
||||
return qb.where((qb) =>
|
||||
qb.or([
|
||||
qb('assets.visibility', '=', AssetVisibility.TIMELINE),
|
||||
qb('assets.visibility', '=', AssetVisibility.ARCHIVE),
|
||||
]),
|
||||
);
|
||||
return qb.where('assets.visibility', 'in', [sql.lit(AssetVisibility.ARCHIVE), sql.lit(AssetVisibility.TIMELINE)]);
|
||||
}
|
||||
|
||||
// TODO come up with a better query that only selects the fields we need
|
||||
export function withExif<O>(qb: SelectQueryBuilder<DB, 'assets', O>) {
|
||||
return qb
|
||||
.leftJoin('exif', 'assets.id', 'exif.assetId')
|
||||
|
||||
Reference in New Issue
Block a user