From 5ad85b6eda8f56f5eba52ef58ee3422f6ad7a8f0 Mon Sep 17 00:00:00 2001 From: Dima Rosmait <dima.rosmait@holi.team> Date: Mon, 6 Nov 2023 10:56:43 +0000 Subject: [PATCH] HOLI-6381 - check space rooms before creating new rooms --- src/handlers/space-created-handler.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/handlers/space-created-handler.ts b/src/handlers/space-created-handler.ts index e27a2da..ac5228e 100644 --- a/src/handlers/space-created-handler.ts +++ b/src/handlers/space-created-handler.ts @@ -2,7 +2,7 @@ import { logPhase } from '../logger' import { SpaceCreatedDataPayload } from '../types' import { addGeneralRoomToSpaceContainer, createSpaceContainer, createSpaceGeneralRoom } from '../helpers/createSpace' import { startChatClient, stopChatClient } from '../helpers/_chatClient' -import { getMatrixUserId } from '../helpers/rooms' +import { getMatrixUserId, getRoomIdsForHoliSpace } from '../helpers/rooms' // Handles the SpaceCreated event from Google Cloud Pub/Sub. export const spaceCreatedHandler = async (messageId: string, payload: SpaceCreatedDataPayload): Promise<void> => { @@ -12,6 +12,10 @@ export const spaceCreatedHandler = async (messageId: string, payload: SpaceCreat const creatorId = getMatrixUserId(creator.identity) try { + // check if Space already has rooms + const rooms = await getRoomIdsForHoliSpace(payload.space.id) + if (rooms.length > 0) return + const parentSpaceRoomId = await logPhase( messageId, 'spaceCreatedHandler.createSpaceContainer' -- GitLab