comms: fix guest renamer db sql quoting
This commit is contained in:
parent
831f368493
commit
d8c3bb2f1b
@ -271,13 +271,13 @@ spec:
|
|||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"SELECT name FROM users WHERE name ~ %s",
|
"SELECT name FROM users WHERE name ~ %s",
|
||||||
(f\"^@\\\\d+:{SERVER_NAME}$\",),
|
(f"^@\\d+:{SERVER_NAME}$",),
|
||||||
)
|
)
|
||||||
user_ids = [row[0] for row in cur.fetchall()]
|
user_ids = [row[0] for row in cur.fetchall()]
|
||||||
if not user_ids:
|
if not user_ids:
|
||||||
return
|
return
|
||||||
cur.execute(
|
cur.execute(
|
||||||
\"SELECT user_id, displayname FROM profiles WHERE user_id = ANY(%s)\",
|
"SELECT user_id, displayname FROM profiles WHERE user_id = ANY(%s)",
|
||||||
(user_ids,),
|
(user_ids,),
|
||||||
)
|
)
|
||||||
profiles = {row[0]: row[1] for row in cur.fetchall()}
|
profiles = {row[0]: row[1] for row in cur.fetchall()}
|
||||||
@ -287,7 +287,7 @@ spec:
|
|||||||
continue
|
continue
|
||||||
new = None
|
new = None
|
||||||
for _ in range(30):
|
for _ in range(30):
|
||||||
candidate = f\"{random.choice(ADJ)}-{random.choice(NOUN)}\"
|
candidate = f"{random.choice(ADJ)}-{random.choice(NOUN)}"
|
||||||
if candidate not in existing_names:
|
if candidate not in existing_names:
|
||||||
new = candidate
|
new = candidate
|
||||||
existing_names.add(candidate)
|
existing_names.add(candidate)
|
||||||
@ -295,7 +295,7 @@ spec:
|
|||||||
if not new:
|
if not new:
|
||||||
continue
|
continue
|
||||||
cur.execute(
|
cur.execute(
|
||||||
\"INSERT INTO profiles (user_id, displayname) VALUES (%s, %s) ON CONFLICT (user_id) DO UPDATE SET displayname = EXCLUDED.displayname\",
|
"INSERT INTO profiles (user_id, displayname) VALUES (%s, %s) ON CONFLICT (user_id) DO UPDATE SET displayname = EXCLUDED.displayname",
|
||||||
(user_id, new),
|
(user_id, new),
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user