tweak(server/player): Added regex replace to getIdentifierByPhoneNumber

Added a regex replace to match the old signature for this function. Also
migrated messages to use the new util function rather than a locally
defined query
This commit is contained in:
Taso committed 2021-03-08 20:35:25 -05:00
1 parent 6e9c3e6d1a
commit 258ea66746
2 files changed
+3 -14

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ export async function getIdentifierByPhoneNumber(
}
// Whether we fetch from database if not found in online players
if (fetch) {
const query = `SELECT identifier FROM users WHERE phone_number = ?`;
const query = `SELECT identifier FROM users WHERE REGEXP_REPLACE(phone_number, '[^0-9]', '') = ? `;
const [results] = await pool.query(query, [phoneNumber]);
// Get identifier from results
return (results as { identifier: string }[])[0].identifier;