This commit is contained in:
leca 2024-08-10 17:39:21 +03:00
parent 5ab9e9b026
commit 96d7cfb7de
2 changed files with 7 additions and 7 deletions

View File

@ -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])

View File

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