mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
* feat: update storage quota used for user based on shared vault files * fix: use case binding * fix: increase file upload bytes limit for shared vaults
20 lines
848 B
TypeScript
20 lines
848 B
TypeScript
import { DomainEventHandlerInterface, SharedVaultFileUploadedEvent } from '@standardnotes/domain-events'
|
|
import { Logger } from 'winston'
|
|
|
|
import { UpdateStorageQuotaUsedForUser } from '../UseCase/UpdateStorageQuotaUsedForUser/UpdateStorageQuotaUsedForUser'
|
|
|
|
export class SharedVaultFileUploadedEventHandler implements DomainEventHandlerInterface {
|
|
constructor(private updateStorageQuotaUsedForUserUseCase: UpdateStorageQuotaUsedForUser, private logger: Logger) {}
|
|
|
|
async handle(event: SharedVaultFileUploadedEvent): Promise<void> {
|
|
const result = await this.updateStorageQuotaUsedForUserUseCase.execute({
|
|
userUuid: event.payload.vaultOwnerUuid,
|
|
bytesUsed: event.payload.fileByteSize,
|
|
})
|
|
|
|
if (result.isFailed()) {
|
|
this.logger.error(`Failed to update storage quota used for user: ${result.getError()}`)
|
|
}
|
|
}
|
|
}
|