mirror of
https://github.com/immich-app/immich.git
synced 2026-03-26 03:28:59 +03:00
refactor: migrate shared-link repository to kysely (#15289)
* refactor: migrate shared-link repository to kysely * fix duplicate individual shared link return in getAll when there are more than 1 asset in the shared link * using correct order condition * using eb.table --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
||||
SharedLinkPasswordDto,
|
||||
SharedLinkResponseDto,
|
||||
} from 'src/dtos/shared-link.dto';
|
||||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
import { SharedLinkEntity } from 'src/entities/shared-link.entity';
|
||||
import { Permission, SharedLinkType } from 'src/enum';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
@@ -67,7 +66,7 @@ export class SharedLinkService extends BaseService {
|
||||
userId: auth.user.id,
|
||||
type: dto.type,
|
||||
albumId: dto.albumId || null,
|
||||
assets: (dto.assetIds || []).map((id) => ({ id }) as AssetEntity),
|
||||
assetIds: dto.assetIds,
|
||||
description: dto.description || null,
|
||||
password: dto.password,
|
||||
expiresAt: dto.expiresAt || null,
|
||||
@@ -138,10 +137,12 @@ export class SharedLinkService extends BaseService {
|
||||
}
|
||||
|
||||
results.push({ assetId, success: true });
|
||||
sharedLink.assets.push({ id: assetId } as AssetEntity);
|
||||
}
|
||||
|
||||
await this.sharedLinkRepository.update(sharedLink);
|
||||
await this.sharedLinkRepository.update({
|
||||
...sharedLink,
|
||||
assetIds: results.filter(({ success }) => success).map(({ assetId }) => assetId),
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user