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; }