mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
* feat(syncing-server): refactor container config into server and worker * fix(syncing-server): yarn lock * fix(api-gateway): add client update response on v1 revision endpoints * fix(syncing-server): linter issue
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import {
|
|
ItemRevisionCreationRequestedEvent,
|
|
DomainEventHandlerInterface,
|
|
DomainEventPublisherInterface,
|
|
} from '@standardnotes/domain-events'
|
|
|
|
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
|
|
import { ItemBackupServiceInterface } from '../Item/ItemBackupServiceInterface'
|
|
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
|
|
|
|
export class ItemRevisionCreationRequestedEventHandler implements DomainEventHandlerInterface {
|
|
constructor(
|
|
private itemRepository: ItemRepositoryInterface,
|
|
private itemBackupService: ItemBackupServiceInterface,
|
|
private domainEventFactory: DomainEventFactoryInterface,
|
|
private domainEventPublisher: DomainEventPublisherInterface,
|
|
) {}
|
|
|
|
async handle(event: ItemRevisionCreationRequestedEvent): Promise<void> {
|
|
const item = await this.itemRepository.findByUuid(event.payload.itemUuid)
|
|
if (item === null) {
|
|
return
|
|
}
|
|
|
|
const fileDumpPath = await this.itemBackupService.dump(item)
|
|
if (fileDumpPath) {
|
|
await this.domainEventPublisher.publish(
|
|
this.domainEventFactory.createItemDumpedEvent(fileDumpPath, event.meta.correlation.userIdentifier),
|
|
)
|
|
}
|
|
}
|
|
}
|