mirror of
https://github.com/colanode/colanode.git
synced 2025-12-25 16:09:31 +01:00
Send event on user created
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user