diff --git a/server/routers/olm/error.ts b/server/routers/olm/error.ts index 978c1a1a..c02c571c 100644 --- a/server/routers/olm/error.ts +++ b/server/routers/olm/error.ts @@ -5,6 +5,7 @@ export const OlmErrorCodes = { CLIENT_ID_NOT_FOUND: "CLIENT_ID_NOT_FOUND", CLIENT_NOT_FOUND: "CLIENT_NOT_FOUND", CLIENT_BLOCKED: "CLIENT_BLOCKED", + CLIENT_PENDING: "CLIENT_PENDING", ORG_NOT_FOUND: "ORG_NOT_FOUND", USER_ID_NOT_FOUND: "USER_ID_NOT_FOUND", INVALID_USER_SESSION: "INVALID_USER_SESSION", diff --git a/server/routers/olm/handleOlmRegisterMessage.ts b/server/routers/olm/handleOlmRegisterMessage.ts index 0c69ce8d..242fe345 100644 --- a/server/routers/olm/handleOlmRegisterMessage.ts +++ b/server/routers/olm/handleOlmRegisterMessage.ts @@ -90,6 +90,18 @@ export const handleOlmRegisterMessage: MessageHandler = async (context) => { return; } + if (client.approvalState == "pending") { + logger.debug( + `Client ${client.clientId} approval is pending. Ignoring register.` + ); + sendOlmError( + OlmErrorCodes.CLIENT_PENDING, + "Client approval is pending", + olm.olmId + ); + return; + } + const [org] = await db .select() .from(orgs)