From 96d7cfb7def12cde27f5f0af0df62e6ff1ea50b0 Mon Sep 17 00:00:00 2001 From: leca Date: Sat, 10 Aug 2024 17:39:21 +0300 Subject: [PATCH] bugfixes --- src/db.js | 5 +++-- src/index.js | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/db.js b/src/db.js index ccb40c8..df70cb7 100644 --- a/src/db.js +++ b/src/db.js @@ -80,6 +80,7 @@ const selectProfilesForUser = async (roomId) => { )) * 6371 <= $5::double precision */ + // AND (range >= $5::double precision AND range != 0) let user = (await db.query(`SELECT room_id, name, age, sex, description, country, city FROM users WHERE @@ -97,9 +98,9 @@ const selectProfilesForUser = async (roomId) => { )) ))` : - `check_distance($6::double precision, $7::double precision, (SELECT lat FROM cities WHERE name = city AND cities.country = country), (SELECT lng FROM cities WHERE name = city AND cities.country = country), range)` + `check_distance($6::double precision, $7::double precision, (SELECT lat FROM cities WHERE name = city AND cities.country = country), (SELECT lng FROM cities WHERE name = city AND cities.country = country), range) + OR range = 0` } - AND (range >= $5::double precision AND range != 0) AND (interest = $4 OR interest = 'b') ORDER BY RANDOM() LIMIT 1`, [myage, roomId, myinterest, mysex, myrange, lat, lng]) diff --git a/src/index.js b/src/index.js index 0d4cf70..4bf236e 100644 --- a/src/index.js +++ b/src/index.js @@ -233,12 +233,11 @@ client.on("room.message", async (roomId, event) => { content = answer; } if (await insertMessageIntoDB(roomId, recipient, msgtype, content)) { - await client.sendText(roomId, i18n.t(["general", "newmessage"])); - + await client.sendText(recipient, i18n.t(["general", "newmessage"])); await client.sendText(roomId, i18n.t(["general", "messagesent"])); } else { - await client.sendText(roomId, i18n.t(["general", "alreadymessaged"])); + await client.sendText(roomId, i18n.t(["errors", "alreadymessaged"])); } await setUserState(roomId, 'view_profiles'); @@ -289,7 +288,7 @@ client.on("room.message", async (roomId, event) => { await client.sendText(roomId, i18n.t(["general", "menu"])); break; default: - await client.sendText(roomId, i18n.t(["general", "didntunderstand"])); + await client.sendText(roomId, i18n.t(["errors", "didntunderstand"])); await client.sendText(roomId, i18n.t(["general", "menu"])); @@ -297,7 +296,7 @@ client.on("room.message", async (roomId, event) => { } break; default: - await client.sendText(roomId, i18n.t(["general", "didntunderstand"])); + await client.sendText(roomId, i18n.t(["errors", "didntunderstand"])); return; }