Send event on user created

This commit is contained in:
Hakan Shehu
2025-01-17 16:47:56 +01:00
parent 4aa249e0fe
commit 2c4b92120f
3 changed files with 26 additions and 1 deletions

View File

@@ -223,8 +223,9 @@ export class AccountService {
private handleMessage(message: Message): void {
if (
message.type === 'account_updated' ||
message.type === 'workspace_deleted' ||
message.type === 'workspace_updated' ||
message.type === 'workspace_deleted'
message.type === 'user_created'
) {
this.eventLoop.trigger();
}

View File

@@ -14,6 +14,7 @@ import {
CollaborationCreatedEvent,
CollaborationUpdatedEvent,
Event,
UserCreatedEvent,
WorkspaceDeletedEvent,
WorkspaceUpdatedEvent,
} from '@/types/events';
@@ -97,6 +98,8 @@ export class SocketConnection {
this.handleCollaborationCreatedEvent(event);
} else if (event.type === 'collaboration_updated') {
this.handleCollaborationUpdatedEvent(event);
} else if (event.type === 'user_created') {
this.handleUserCreatedEvent(event);
}
for (const user of this.users.values()) {
@@ -373,4 +376,17 @@ export class SocketConnection {
user.rootIds.add(event.entryId);
}
}
private handleUserCreatedEvent(event: UserCreatedEvent) {
if (event.accountId !== this.account.id) {
return;
}
this.sendMessage({
type: 'user_created',
accountId: event.accountId,
workspaceId: event.workspaceId,
userId: event.userId,
});
}
}

View File

@@ -33,9 +33,17 @@ export type WorkspaceDeletedMessage = {
accountId: string;
};
export type UserCreatedMessage = {
type: 'user_created';
accountId: string;
workspaceId: string;
userId: string;
};
export type Message =
| AccountUpdatedMessage
| WorkspaceUpdatedMessage
| WorkspaceDeletedMessage
| UserCreatedMessage
| SynchronizerInputMessage
| SynchronizerOutputMessage<SynchronizerInput>;