mirror of
https://github.com/standardnotes/server
synced 2026-08-03 06:15:59 -04:00
wip: default rotation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user