Files
immich/server/src/repositories/download.repository.ts
Alex d33ce13561 feat(server): visibility column (#17939)
* feat: private view

* pr feedback

* sql generation

* feat: visibility column

* fix: set visibility value as the same as the still part after unlinked live photos

* fix: test

* pr feedback
2025-05-06 12:12:48 -05:00

41 lines
1.3 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import { Kysely } from 'kysely';
import { InjectKysely } from 'nestjs-kysely';
import { DB } from 'src/db';
import { AssetVisibility } from 'src/enum';
import { anyUuid } from 'src/utils/database';
const builder = (db: Kysely<DB>) =>
db
.selectFrom('assets')
.innerJoin('exif', 'assetId', 'id')
.select(['assets.id', 'assets.livePhotoVideoId', 'exif.fileSizeInByte as size'])
.where('assets.deletedAt', 'is', null);
@Injectable()
export class DownloadRepository {
constructor(@InjectKysely() private db: Kysely<DB>) {}
downloadAssetIds(ids: string[]) {
return builder(this.db).where('assets.id', '=', anyUuid(ids)).stream();
}
downloadMotionAssetIds(ids: string[]) {
return builder(this.db).select(['assets.originalPath']).where('assets.id', '=', anyUuid(ids)).stream();
}
downloadAlbumId(albumId: string) {
return builder(this.db)
.innerJoin('albums_assets_assets', 'assets.id', 'albums_assets_assets.assetsId')
.where('albums_assets_assets.albumsId', '=', albumId)
.stream();
}
downloadUserId(userId: string) {
return builder(this.db)
.where('assets.ownerId', '=', userId)
.where('assets.visibility', '!=', AssetVisibility.HIDDEN)
.stream();
}
}