mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 15:31:11 -04:00
[user] circle - ignore @
This commit is contained in:
parent
8092bf8408
commit
61702f684b
@ -131,14 +131,14 @@ const usernamesToIds = async(db, usernames) => {
|
|||||||
const users = await db.all(SQL`
|
const users = await db.all(SQL`
|
||||||
SELECT id, usernameNorm
|
SELECT id, usernameNorm
|
||||||
FROM users
|
FROM users
|
||||||
WHERE users.usernameNorm IN (`.append(usernames.map(k => `'${normalise(k)}'`).join(',')).append(SQL`)`
|
WHERE users.usernameNorm IN (`.append(usernames.map(k => `'${normalise(k.replace(/^@/g, ''))}'`).join(',')).append(SQL`)`
|
||||||
));
|
));
|
||||||
|
|
||||||
const idMap = {}
|
const idMap = {}
|
||||||
for (let username of usernames) {
|
for (let username of usernames) {
|
||||||
for (let {id, usernameNorm} of users) {
|
for (let {id, usernameNorm} of users) {
|
||||||
if (normalise(username) === usernameNorm) {
|
if (normalise(username.replace(/^@/g, '')) === usernameNorm) {
|
||||||
idMap[normalise(username)] = id;
|
idMap[normalise(username.replace(/^@/g, ''))] = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => {
|
|||||||
await req.db.get(SQL`DELETE FROM user_connections WHERE from_profileId = ${profileId}`);
|
await req.db.get(SQL`DELETE FROM user_connections WHERE from_profileId = ${profileId}`);
|
||||||
const usernameIdMap = await usernamesToIds(req.db, req.body.circle.map(r => r.username));
|
const usernameIdMap = await usernamesToIds(req.db, req.body.circle.map(r => r.username));
|
||||||
for (let connection of req.body.circle) {
|
for (let connection of req.body.circle) {
|
||||||
const toUserId = usernameIdMap[normalise(connection.username)];
|
const toUserId = usernameIdMap[normalise(connection.username.replace(/^@/g, ''))];
|
||||||
const relationship = connection.relationship.substring(0, 64).trim();
|
const relationship = connection.relationship.substring(0, 64).trim();
|
||||||
if (toUserId === undefined || !relationship) { continue; }
|
if (toUserId === undefined || !relationship) { continue; }
|
||||||
await req.db.get(SQL`INSERT INTO user_connections (id, from_profileId, to_userId, relationship) VALUES (
|
await req.db.get(SQL`INSERT INTO user_connections (id, from_profileId, to_userId, relationship) VALUES (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user