fix: add to shared link (#26886)

This commit is contained in:
Jason Rasmussen
2026-03-12 16:10:55 -04:00
committed by GitHub
parent 001d7d083f
commit 990aff441b
4 changed files with 33 additions and 14 deletions

View File

@@ -4,7 +4,7 @@ import { jsonArrayFrom, jsonObjectFrom } from 'kysely/helpers/postgres';
import _ from 'lodash';
import { InjectKysely } from 'nestjs-kysely';
import { Album, columns } from 'src/database';
import { DummyValue, GenerateSql } from 'src/decorators';
import { ChunkedArray, DummyValue, GenerateSql } from 'src/decorators';
import { SharedLinkType } from 'src/enum';
import { DB } from 'src/schema';
import { AssetExifTable } from 'src/schema/tables/asset-exif.table';
@@ -249,6 +249,20 @@ export class SharedLinkRepository {
await this.db.deleteFrom('shared_link').where('shared_link.id', '=', id).execute();
}
@ChunkedArray({ paramIndex: 1 })
async addAssets(id: string, assetIds: string[]) {
if (assetIds.length === 0) {
return [];
}
return await this.db
.insertInto('shared_link_asset')
.values(assetIds.map((assetId) => ({ assetId, sharedLinkId: id })))
.onConflict((oc) => oc.doNothing())
.returning(['shared_link_asset.assetId'])
.execute();
}
@GenerateSql({ params: [DummyValue.UUID] })
private getSharedLinks(id: string) {
return this.db