From 27bdd2e15bd3fd5f29a3f266c2e4bbad9ad72948 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Wed, 29 Mar 2023 19:19:58 +0200 Subject: [PATCH] joinpublicromm error msg fix --- src/api/acts/rooms.ts | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/api/acts/rooms.ts b/src/api/acts/rooms.ts index 3651374..8579f51 100644 --- a/src/api/acts/rooms.ts +++ b/src/api/acts/rooms.ts @@ -316,21 +316,25 @@ export const joinPublicRoom: Act = { return void aws("error", "existence"); } if (await isRoomFull(roomID)) return void aws("error", "limit"); - let queryx = await insert( - roomMembers.roomID, - roomMembers.name, - roomMembers.server, - roomMembers.admin - ).add( - roomID, - client.name, - client.state == STATE.remote ? client.server.tag : "local", - 0 - ).query(db); - if (queryx.affectedRows > 0) { - aws("ok", ""); - } else { - aws("error", "server"); + try { + let queryx = await insert( + roomMembers.roomID, + roomMembers.name, + roomMembers.server, + roomMembers.admin + ).add( + roomID, + client.name, + client.state == STATE.remote ? client.server.tag : "local", + 0 + ).query(db); + if (queryx.affectedRows > 0) { + aws("ok", ""); + } else { + aws("error", "duplicate"); + } + } catch (error) { + aws("error", "duplicate"); } } };