fix(server): enforce strict equality (===)

- asset.repository: use === undefined (consistent with other
  visibility checks at lines 709/766)
- bytes: magnitude === 0 for number comparison
- storage-template: asset.type === AssetType.Image

All three were loose == which allows coercion and is flagged by
eqeqeq / type-aware lint.
This commit is contained in:
pxmpsdev 2026-08-09 21:33:40 +00:00
parent 35c2a90fca
commit 7a2b016bc0
3 changed files with 4 additions and 4 deletions

View file

@ -838,7 +838,7 @@ export class AssetRepository {
)
.$if(!!options.withCoordinates, (qb) => qb.select(['asset_exif.latitude', 'asset_exif.longitude']))
.where('asset.deletedAt', options.isTrashed ? 'is not' : 'is', null)
.$if(options.visibility == undefined, withDefaultVisibility)
.$if(options.visibility === undefined, withDefaultVisibility)
.$if(!!options.visibility, (qb) => qb.where('asset.visibility', '=', options.visibility!))
.$if(!!options.bbox, (qb) => {
const bbox = options.bbox!;

View file

@ -402,8 +402,8 @@ export class StorageTemplateService extends BaseService {
const substitutions: Record<string, string> = {
filename,
ext: extension,
filetype: asset.type == AssetType.Image ? 'IMG' : 'VID',
filetypefull: asset.type == AssetType.Image ? 'IMAGE' : 'VIDEO',
filetype: asset.type === AssetType.Image ? 'IMG' : 'VID',
filetypefull: asset.type === AssetType.Image ? 'IMAGE' : 'VIDEO',
assetId: asset.id,
assetIdShort: asset.id.slice(-12),
//just throw into the root if it doesn't belong to an album

View file

@ -20,7 +20,7 @@ export function asHumanReadable(bytes: number, precision = 1): string {
}
}
return `${remainder.toFixed(magnitude == 0 ? 0 : precision)} ${units[magnitude]}`;
return `${remainder.toFixed(magnitude === 0 ? 0 : precision)} ${units[magnitude]}`;
}
// if an asset is jsonified in the DB before being returned, its buffer fields will be hex-encoded strings