feat: enhance comments (#1980)

* feat: non-inline comments support

* enhance comments

* fix types
This commit is contained in:
Philip Okugbe
2026-03-02 01:42:25 +00:00
committed by GitHub
parent d5e4b8bb59
commit 4f3577f009
12 changed files with 310 additions and 184 deletions
+28 -3
View File
@@ -45,7 +45,7 @@ export class WsService {
return;
}
await this.broadcastToAuthorizedUsers(client, room, pageId, data);
await this.broadcastToAuthorizedUsers(room, client.data.userId, pageId, data);
}
async invalidateSpaceRestrictionCache(spaceId: string): Promise<void> {
@@ -54,6 +54,29 @@ export class WsService {
);
}
async emitCommentEvent(
spaceId: string,
pageId: string,
data: any,
): Promise<void> {
const room = getSpaceRoomName(spaceId);
const hasRestrictions = await this.spaceHasRestrictions(spaceId);
if (!hasRestrictions) {
this.server.to(room).emit('message', data);
return;
}
const isRestricted =
await this.pagePermissionRepo.hasRestrictedAncestor(pageId);
if (!isRestricted) {
this.server.to(room).emit('message', data);
return;
}
await this.broadcastToAuthorizedUsers(room, null, pageId, data);
}
async emitToUsers(userIds: string[], data: any): Promise<void> {
if (userIds.length === 0) return;
const rooms = userIds.map((id) => getUserRoomName(id));
@@ -82,14 +105,16 @@ export class WsService {
}
private async broadcastToAuthorizedUsers(
sender: Socket,
room: string,
excludeUserId: string | null,
pageId: string,
data: any,
): Promise<void> {
const sockets = await this.server.in(room).fetchSockets();
const otherSockets = sockets.filter((s) => s.id !== sender.id);
const otherSockets = excludeUserId
? sockets.filter((s) => s.data.userId !== excludeUserId)
: sockets;
if (otherSockets.length === 0) return;
const userSocketMap = new Map<string, typeof otherSockets>();