2023-03-30 15:38:55 -04:00
|
|
|
import { AssetEntity, AssetType } from '@app/infra/entities';
|
2023-03-05 15:44:31 -05:00
|
|
|
import { IJobRepository, JobName } from '../job';
|
2023-03-02 21:47:08 -05:00
|
|
|
import { AssetSearchOptions, IAssetRepository } from './asset.repository';
|
|
|
|
|
|
|
|
export class AssetCore {
|
2023-03-05 15:44:31 -05:00
|
|
|
constructor(private assetRepository: IAssetRepository, private jobRepository: IJobRepository) {}
|
2023-03-02 21:47:08 -05:00
|
|
|
|
|
|
|
getAll(options: AssetSearchOptions) {
|
2023-03-05 15:44:31 -05:00
|
|
|
return this.assetRepository.getAll(options);
|
2023-03-02 21:47:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
async save(asset: Partial<AssetEntity>) {
|
2023-03-05 15:44:31 -05:00
|
|
|
const _asset = await this.assetRepository.save(asset);
|
2023-03-18 08:44:42 -05:00
|
|
|
await this.jobRepository.queue({
|
|
|
|
name: JobName.SEARCH_INDEX_ASSET,
|
|
|
|
data: { ids: [_asset.id] },
|
|
|
|
});
|
2023-03-02 21:47:08 -05:00
|
|
|
return _asset;
|
|
|
|
}
|
|
|
|
|
|
|
|
findLivePhotoMatch(livePhotoCID: string, otherAssetId: string, type: AssetType): Promise<AssetEntity | null> {
|
2023-03-05 15:44:31 -05:00
|
|
|
return this.assetRepository.findLivePhotoMatch(livePhotoCID, otherAssetId, type);
|
2023-03-02 21:47:08 -05:00
|
|
|
}
|
|
|
|
}
|