mirror of
https://github.com/standardnotes/server
synced 2026-10-21 06:03:37 -04:00
feat: send event to client upon items change on server (#941)
* feat(websockets): persist connections in mysql * fix: add sending event to client upon items changed on server * fix payload * fix: add cathcing errors * fix: send changed items event only on a 10% dice roll
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
ItemDumpedEvent,
|
||||
ItemRemovedFromSharedVaultEvent,
|
||||
ItemRevisionCreationRequestedEvent,
|
||||
ItemsChangedOnServerEvent,
|
||||
MessageSentToUserEvent,
|
||||
NotificationAddedForUserEvent,
|
||||
RevisionsCopyRequestedEvent,
|
||||
@@ -23,6 +24,25 @@ import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
|
||||
export class DomainEventFactory implements DomainEventFactoryInterface {
|
||||
constructor(private timer: TimerInterface) {}
|
||||
|
||||
createItemsChangedOnServerEvent(dto: {
|
||||
userUuid: string
|
||||
sessionUuid: string
|
||||
timestamp: number
|
||||
}): ItemsChangedOnServerEvent {
|
||||
return {
|
||||
type: 'ITEMS_CHANGED_ON_SERVER',
|
||||
createdAt: this.timer.getUTCDate(),
|
||||
meta: {
|
||||
correlation: {
|
||||
userIdentifier: dto.userUuid,
|
||||
userIdentifierType: 'uuid',
|
||||
},
|
||||
origin: DomainEventService.SyncingServer,
|
||||
},
|
||||
payload: dto,
|
||||
}
|
||||
}
|
||||
|
||||
createAccountDeletionVerificationPassedEvent(dto: {
|
||||
userUuid: string
|
||||
email: string
|
||||
@@ -207,7 +227,11 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
||||
}
|
||||
}
|
||||
|
||||
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: string }): WebSocketMessageRequestedEvent {
|
||||
createWebSocketMessageRequestedEvent(dto: {
|
||||
userUuid: string
|
||||
message: string
|
||||
originatingSessionUuid?: string
|
||||
}): WebSocketMessageRequestedEvent {
|
||||
return {
|
||||
type: 'WEB_SOCKET_MESSAGE_REQUESTED',
|
||||
createdAt: this.timer.getUTCDate(),
|
||||
|
||||
Reference in New Issue
Block a user