summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-01-23 09:18:54 +0100
committerRory& <root@rory.gay>2026-01-23 09:18:54 +0100
commit9368066ec5fecd8e6da3eec713c2043a290d843a (patch)
treedbe6e3b7044d57231619433e404206134e6ef78a
parentMake openapi.js work offline - still needs conditionals fixed though (diff)
downloadserver-ts-9368066ec5fecd8e6da3eec713c2043a290d843a.tar.xz
Port User.tag getter from pomelo as utility
-rw-r--r--assets/openapi.json4
-rw-r--r--assets/schemas.json4
-rw-r--r--src/api/routes/auth/forgot.ts2
-rw-r--r--src/api/routes/auth/verify/resend.ts2
-rw-r--r--src/util/entities/User.ts9
5 files changed, 18 insertions, 3 deletions
diff --git a/assets/openapi.json b/assets/openapi.json

index 298ad18e..3c573188 100644 --- a/assets/openapi.json +++ b/assets/openapi.json
@@ -7627,6 +7627,9 @@ "type": "string" } }, + "tag": { + "type": "string" + }, "id": { "type": "string" } @@ -7658,6 +7661,7 @@ "security_keys", "sessions", "system", + "tag", "username", "verified", "webauthn_enabled" diff --git a/assets/schemas.json b/assets/schemas.json
index a7d759fa..46a36939 100644 --- a/assets/schemas.json +++ b/assets/schemas.json
@@ -8097,6 +8097,9 @@ "type": "string" } }, + "tag": { + "type": "string" + }, "id": { "type": "string" } @@ -8129,6 +8132,7 @@ "security_keys", "sessions", "system", + "tag", "username", "verified", "webauthn_enabled" diff --git a/src/api/routes/auth/forgot.ts b/src/api/routes/auth/forgot.ts
index 26e1b353..4ebb9654 100644 --- a/src/api/routes/auth/forgot.ts +++ b/src/api/routes/auth/forgot.ts
@@ -68,7 +68,7 @@ router.post( if (user && user.email) { Email.sendResetPassword(user, user.email).catch((e) => { - console.error(`Failed to send password reset email to ${user.username}#${user.discriminator} (${user.id}): ${e}`); + console.error(`Failed to send password reset email to ${user.tag} (${user.id}): ${e}`); }); } }, diff --git a/src/api/routes/auth/verify/resend.ts b/src/api/routes/auth/verify/resend.ts
index 4c0339bf..453c616d 100644 --- a/src/api/routes/auth/verify/resend.ts +++ b/src/api/routes/auth/verify/resend.ts
@@ -56,7 +56,7 @@ router.post( return res.sendStatus(204); }) .catch((e) => { - console.error(`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`); + console.error(`Failed to send verification email to ${user.tag}: ${e}`); throw new HTTPError("Failed to send verification email", 500); }); }, diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index 84471e0d..d3c01c1a 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts
@@ -245,6 +245,13 @@ export class User extends BaseClass { } } + public get tag(): string { + //const { uniqueUsernames } = Config.get().general; + const uniqueUsernames = false; + + return uniqueUsernames ? this.username : `${this.username}#${this.discriminator}`; + } + static async register({ email, username, @@ -310,7 +317,7 @@ export class User extends BaseClass { // send verification email if users aren't verified by default and we have an email if (!Config.get().defaults.user.verified && email) { await Email.sendVerifyEmail(user, email).catch((e) => { - console.error(`Failed to send verification email to ${user.username}#${user.discriminator}: ${e}`); + console.error(`Failed to send verification email to ${user.tag}: ${e}`); }); }