feat: Prevent deleted users from crashing the entire fucking server

This commit is contained in:
April Hall 2025-02-25 02:48:17 -05:00
parent a33437cac6
commit 3c99016687
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C

View File

@ -25,8 +25,10 @@ class AuthDb {
getUser(userId: string): Profile { getUser(userId: string): Profile {
const row = this.client.prepare('SELECT username, image FROM user WHERE id = ?').get(userId); const row = this.client.prepare('SELECT username, image FROM user WHERE id = ?').get(userId);
return { return {
username: (row as Profile).username, // If user is deleted, UID gets truncated to 7 to that the displayed name for the
image: (row as Profile).image ?? `https://api.dicebear.com/9.x/identicon/svg?seed=${userId}`, // deleted user won't go above 15 characters long.
username: (row as Profile)?.username ?? `DELETED-${userId.slice(0, 7)}`,
image: (row as Profile)?.image ?? `https://api.dicebear.com/9.x/identicon/svg?seed=${userId}`,
}; };
} }
} }