mirror of
https://github.com/standardnotes/server
synced 2026-08-03 06:15:59 -04:00
* fix(auth): safe guard file upload bytes used to be positive intiger * feat: add procedure for recalculating file quota for user * add more meta to logs
34 lines
963 B
TypeScript
34 lines
963 B
TypeScript
import { DomainEventHandlerInterface, FileQuotaRecalculationRequestedEvent } from '@standardnotes/domain-events'
|
|
import { Logger } from 'winston'
|
|
|
|
import { RecalculateQuota } from '../UseCase/RecalculateQuota/RecalculateQuota'
|
|
|
|
export class FileQuotaRecalculationRequestedEventHandler implements DomainEventHandlerInterface {
|
|
constructor(
|
|
private recalculateQuota: RecalculateQuota,
|
|
private logger: Logger,
|
|
) {}
|
|
|
|
async handle(event: FileQuotaRecalculationRequestedEvent): Promise<void> {
|
|
this.logger.info('Recalculating quota for user...', {
|
|
userId: event.payload.userUuid,
|
|
})
|
|
|
|
const result = await this.recalculateQuota.execute({
|
|
userUuid: event.payload.userUuid,
|
|
})
|
|
|
|
if (result.isFailed()) {
|
|
this.logger.error('Could not recalculate quota', {
|
|
userId: event.payload.userUuid,
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
this.logger.info('Quota recalculated', {
|
|
userId: event.payload.userUuid,
|
|
})
|
|
}
|
|
}
|