mirror of
https://github.com/standardnotes/server
synced 2026-07-14 00:01:54 -04:00
18 lines
849 B
TypeScript
18 lines
849 B
TypeScript
import { DomainEventHandlerInterface, UserCredentialsChangedEvent } from '@standardnotes/domain-events'
|
|
import { TimerInterface } from '@standardnotes/time'
|
|
import { ContactsRepositoryInterface } from '../Contact/Repository/ContactRepositoryInterface'
|
|
|
|
export class UserCredentialsChangedEventHandler implements DomainEventHandlerInterface {
|
|
constructor(private contactRepository: ContactsRepositoryInterface, private timer: TimerInterface) {}
|
|
|
|
async handle(event: UserCredentialsChangedEvent): Promise<void> {
|
|
const contacts = await this.contactRepository.findAll({ contactUuid: event.payload.userUuid })
|
|
|
|
for (const contact of contacts) {
|
|
contact.contactPublicKey = event.payload.newPublicKey
|
|
contact.updatedAtTimestamp = this.timer.getTimestampInMicroseconds()
|
|
await this.contactRepository.save(contact)
|
|
}
|
|
}
|
|
}
|