summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-19 17:32:52 +0100
committerRory& <root@rory.gay>2025-12-19 17:33:11 +0100
commit11a0744edc6802d98b72a273b459ae24695f0e62 (patch)
tree106e18dd84cddc0a57c959d2f28d12046489c3d4
parentMerge pull request #1446 from CyberL1/refactor/gh-embed-length (diff)
downloadserver-ts-11a0744edc6802d98b72a273b459ae24695f0e62.tar.xz
DEPRECATION: Move most select queries to object instead of string[]
-rw-r--r--.idea/workspace.xml84
-rw-r--r--src/api/routes/applications/#application_id/index.ts2
-rw-r--r--src/api/routes/applications/@me.ts2
-rw-r--r--src/api/routes/auth/forgot.ts2
-rw-r--r--src/api/routes/auth/login.ts2
-rw-r--r--src/api/routes/auth/mfa/totp.ts2
-rw-r--r--src/api/routes/auth/mfa/webauthn.ts2
-rw-r--r--src/api/routes/auth/register.ts2
-rw-r--r--src/api/routes/auth/verify/resend.ts2
-rw-r--r--src/api/routes/auth/verify/view-backup-codes-challenge.ts2
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts2
-rw-r--r--src/api/routes/channels/#channel_id/messages/search.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/delete.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/messages/search.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/roles/member-counts.ts2
-rw-r--r--src/api/routes/oauth2/authorize.ts11
-rw-r--r--src/api/routes/safety-hub/@me/index.ts2
-rw-r--r--src/api/routes/safety-hub/suspended/@me.ts2
-rw-r--r--src/api/routes/teams.ts2
-rw-r--r--src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts13
-rw-r--r--src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts2
-rw-r--r--src/api/routes/users/@me/connections/index.ts13
-rw-r--r--src/api/routes/users/@me/delete.ts2
-rw-r--r--src/api/routes/users/@me/disable.ts2
-rw-r--r--src/api/routes/users/@me/guilds.ts2
-rw-r--r--src/api/routes/users/@me/guilds/#guild_id/settings.ts4
-rw-r--r--src/api/routes/users/@me/mfa/codes.ts2
-rw-r--r--src/api/routes/users/@me/mfa/totp/disable.ts2
-rw-r--r--src/api/routes/users/@me/mfa/totp/enable.ts2
-rw-r--r--src/api/routes/users/@me/mfa/webauthn/credentials/index.ts2
-rw-r--r--src/api/routes/users/@me/relationships.ts2
-rw-r--r--src/gateway/opcodes/Identify.ts4
-rw-r--r--src/gateway/opcodes/PresenceUpdate.ts2
-rw-r--r--src/util/entities/Member.ts4
-rw-r--r--src/util/entities/User.ts4
-rw-r--r--src/util/util/Permissions.ts2
37 files changed, 110 insertions, 85 deletions
diff --git a/.idea/workspace.xml b/.idea/workspace.xml

index ee60e5f8..25a9866f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml
@@ -50,49 +50,50 @@ <option name="hideEmptyMiddlePackages" value="true" /> <option name="showLibraryContents" value="true" /> </component> - <component name="PropertiesComponent">{ - &quot;keyToString&quot;: { - &quot;NIXITCH_NIXPKGS_CONFIG&quot;: &quot;/etc/nix/nixpkgs-config.nix&quot;, - &quot;NIXITCH_NIX_CONF_DIR&quot;: &quot;&quot;, - &quot;NIXITCH_NIX_OTHER_STORES&quot;: &quot;&quot;, - &quot;NIXITCH_NIX_PATH&quot;: &quot;/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source&quot;, - &quot;NIXITCH_NIX_PROFILES&quot;: &quot;/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile&quot;, - &quot;NIXITCH_NIX_REMOTE&quot;: &quot;&quot;, - &quot;NIXITCH_NIX_USER_PROFILE_DIR&quot;: &quot;/nix/var/nix/profiles/per-user/Rory&quot;, - &quot;Node.js.Server.ts.executor&quot;: &quot;Debug&quot;, - &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, - &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, - &quot;git-widget-placeholder&quot;: &quot;master&quot;, - &quot;javascript.nodejs.core.library.configured.version&quot;: &quot;24.8.0&quot;, - &quot;javascript.nodejs.core.library.typings.version&quot;: &quot;24.7.0&quot;, - &quot;last_opened_file_path&quot;: &quot;/home/Rory/git/spacebar/server-master/src/util/migration/postgres&quot;, - &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, - &quot;node.js.detected.package.standard&quot;: &quot;true&quot;, - &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, - &quot;node.js.selected.package.standard&quot;: &quot;&quot;, - &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, - &quot;nodejs_interpreter_path&quot;: &quot;node&quot;, - &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, - &quot;npm.Start API.executor&quot;: &quot;Run&quot;, - &quot;npm.Start CDN.executor&quot;: &quot;Run&quot;, - &quot;npm.Start Gateway.executor&quot;: &quot;Run&quot;, - &quot;npm.build.executor&quot;: &quot;Run&quot;, - &quot;npm.start.executor&quot;: &quot;Debug&quot;, - &quot;prettierjs.PrettierConfiguration.Package&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/prettier&quot;, - &quot;settings.editor.selected.configurable&quot;: &quot;com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable&quot;, - &quot;ts.external.directory.path&quot;: &quot;/home/Rory/git/spacebar/server-master/node_modules/typescript/lib&quot; + <component name="PropertiesComponent"><![CDATA[{ + "keyToString": { + "NIXITCH_NIXPKGS_CONFIG": "/etc/nix/nixpkgs-config.nix", + "NIXITCH_NIX_CONF_DIR": "", + "NIXITCH_NIX_OTHER_STORES": "", + "NIXITCH_NIX_PATH": "/home/Rory/.nix-defexpr/channels:nixpkgs=/nix/store/wb6agba4kfsxpbnb5hzlq58vkjzvbsk6-source", + "NIXITCH_NIX_PROFILES": "/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/Rory /home/Rory/.local/state/nix/profile /nix/profile /home/Rory/.nix-profile", + "NIXITCH_NIX_REMOTE": "", + "NIXITCH_NIX_USER_PROFILE_DIR": "/nix/var/nix/profiles/per-user/Rory", + "Node.js.Server.ts.executor": "Debug", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "master", + "javascript.nodejs.core.library.configured.version": "24.11.1", + "javascript.nodejs.core.library.typings.version": "24.10.4", + "last_opened_file_path": "/home/Rory/git/spacebar/server-master/src/util/migration/postgres", + "node.js.detected.package.eslint": "true", + "node.js.detected.package.standard": "true", + "node.js.selected.package.eslint": "(autodetect)", + "node.js.selected.package.standard": "", + "node.js.selected.package.tslint": "(autodetect)", + "nodejs_interpreter_path": "node", + "nodejs_package_manager_path": "npm", + "npm.Start API.executor": "Run", + "npm.Start CDN.executor": "Run", + "npm.Start Gateway.executor": "Run", + "npm.build.executor": "Run", + "npm.build:src.executor": "Run", + "npm.start.executor": "Debug", + "prettierjs.PrettierConfiguration.Package": "/home/Rory/git/spacebar/server-master/node_modules/prettier", + "settings.editor.selected.configurable": "com.github.copilot.settings.customInstructions.CopilotInstructionsConfigurable", + "ts.external.directory.path": "/home/Rory/git/spacebar/server-master/node_modules/typescript/lib" }, - &quot;keyToStringList&quot;: { - &quot;DatabaseDriversLRU&quot;: [ - &quot;postgresql&quot; + "keyToStringList": { + "DatabaseDriversLRU": [ + "postgresql" ], - &quot;GitStage.ChangesTree.GroupingKeys&quot;: [ - &quot;directory&quot;, - &quot;module&quot;, - &quot;repository&quot; + "GitStage.ChangesTree.GroupingKeys": [ + "directory", + "module", + "repository" ] } -}</component> +}]]></component> <component name="RecentsManager"> <key name="CopyFile.RECENT_KEYS"> <recent name="$PROJECT_DIR$/src/util/migration/postgres" /> @@ -124,14 +125,15 @@ <entry key="Start CDN" value="STOPPED" /> <entry key="Start Gateway" value="STOPPED" /> <entry key="Start bundle" value="STOPPED" /> - <entry key="build" value="FAILED" /> + <entry key="build" value="STOPPED" /> + <entry key="build:src" value="STOPPED" /> </map> </value> </entry> </map> </option> </component> - <component name="RunManager" selected="npm.Start CDN"> + <component name="RunManager" selected="Compound.Start separated"> <list> <item itemvalue="Compound.Start separated" /> <item itemvalue="npm.Start API" /> diff --git a/src/api/routes/applications/#application_id/index.ts b/src/api/routes/applications/#application_id/index.ts
index bf29f404..22340e9e 100644 --- a/src/api/routes/applications/#application_id/index.ts +++ b/src/api/routes/applications/#application_id/index.ts
@@ -83,7 +83,7 @@ router.patch( if (body.guild_id) { const guild = await Guild.findOneOrFail({ where: { id: body.guild_id }, - select: ["owner_id"], + select: { owner_id: true }, }); if (guild.owner_id != req.user_id) throw new HTTPError("You must be the owner of the guild to link it to an application", 400); } diff --git a/src/api/routes/applications/@me.ts b/src/api/routes/applications/@me.ts
index c1cf0db0..1c4a7530 100644 --- a/src/api/routes/applications/@me.ts +++ b/src/api/routes/applications/@me.ts
@@ -79,7 +79,7 @@ router.patch( if (body.guild_id) { const guild = await Guild.findOneOrFail({ where: { id: body.guild_id }, - select: ["owner_id"], + select: { owner_id: true }, }); if (guild.owner_id != req.user_id) throw new HTTPError("You must be the owner of the guild to link it to an application", 400); } diff --git a/src/api/routes/auth/forgot.ts b/src/api/routes/auth/forgot.ts
index db16c3be..26e1b353 100644 --- a/src/api/routes/auth/forgot.ts +++ b/src/api/routes/auth/forgot.ts
@@ -63,7 +63,7 @@ router.post( const user = await User.findOne({ where: [{ phone: login }, { email: login }], - select: ["username", "id", "email"], + select: { username: true, id: true, email: true }, }).catch(() => {}); if (user && user.email) { diff --git a/src/api/routes/auth/login.ts b/src/api/routes/auth/login.ts
index 911ad4a9..8b2e039a 100644 --- a/src/api/routes/auth/login.ts +++ b/src/api/routes/auth/login.ts
@@ -67,7 +67,7 @@ router.post( const user = await User.findOneOrFail({ where: [{ phone: login }, { email: login }], - select: ["data", "id", "disabled", "deleted", "totp_secret", "mfa_enabled", "webauthn_enabled", "security_keys", "verified"], + select: { data: true, id: true, disabled: true, deleted: true, totp_secret: true, mfa_enabled: true, webauthn_enabled: true, security_keys: true, verified: true }, relations: ["security_keys", "settings"], }).catch(() => { throw FieldErrors({ diff --git a/src/api/routes/auth/mfa/totp.ts b/src/api/routes/auth/mfa/totp.ts
index b9f2fa85..dd107698 100644 --- a/src/api/routes/auth/mfa/totp.ts +++ b/src/api/routes/auth/mfa/totp.ts
@@ -45,7 +45,7 @@ router.post( where: { totp_last_ticket: ticket, }, - select: ["id", "totp_secret"], + select: { id: true, totp_secret: true }, relations: ["settings"], }); diff --git a/src/api/routes/auth/mfa/webauthn.ts b/src/api/routes/auth/mfa/webauthn.ts
index da476ab4..0bc91cfe 100644 --- a/src/api/routes/auth/mfa/webauthn.ts +++ b/src/api/routes/auth/mfa/webauthn.ts
@@ -54,7 +54,7 @@ router.post( where: { totp_last_ticket: ticket, }, - select: ["id"], + select: { id: true }, relations: ["settings"], }); diff --git a/src/api/routes/auth/register.ts b/src/api/routes/auth/register.ts
index f1487589..3e3f2924 100644 --- a/src/api/routes/auth/register.ts +++ b/src/api/routes/auth/register.ts
@@ -111,7 +111,7 @@ router.post( // TODO: check if fingerprint was eligible generated const exists = await User.findOne({ where: { fingerprints: body.fingerprint }, - select: ["id"], + select: { id: true }, }); if (exists) { diff --git a/src/api/routes/auth/verify/resend.ts b/src/api/routes/auth/verify/resend.ts
index ce6672a7..4c0339bf 100644 --- a/src/api/routes/auth/verify/resend.ts +++ b/src/api/routes/auth/verify/resend.ts
@@ -39,7 +39,7 @@ router.post( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["username", "email", "verified"], + select: { username: true, email: true, verified: true }, }); if (!user.email) { diff --git a/src/api/routes/auth/verify/view-backup-codes-challenge.ts b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
index d3d40d3e..7bfd6696 100644 --- a/src/api/routes/auth/verify/view-backup-codes-challenge.ts +++ b/src/api/routes/auth/verify/view-backup-codes-challenge.ts
@@ -37,7 +37,7 @@ router.post( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); if (!(await bcrypt.compare(password, user.data.hash || ""))) { diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts
index 45b7d790..be97e445 100644 --- a/src/api/routes/channels/#channel_id/invites.ts +++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -46,7 +46,7 @@ router.post( const { channel_id } = req.params; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, - select: ["id", "name", "type", "guild_id"], + select: { id: true, name: true, type: true, guild_id: true }, }); isTextChannel(channel.type); diff --git a/src/api/routes/channels/#channel_id/messages/search.ts b/src/api/routes/channels/#channel_id/messages/search.ts
index bec9a44c..ed1dfc33 100644 --- a/src/api/routes/channels/#channel_id/messages/search.ts +++ b/src/api/routes/channels/#channel_id/messages/search.ts
@@ -45,7 +45,7 @@ router.get( const { channel_id } = req.params; const channel = await Channel.findOneOrFail({ where: { guild_id: req.params.guild_id }, - select: ["id"], + select: { id: true }, }); const { content, diff --git a/src/api/routes/guilds/#guild_id/delete.ts b/src/api/routes/guilds/#guild_id/delete.ts
index 4edd2c39..6e541da1 100644 --- a/src/api/routes/guilds/#guild_id/delete.ts +++ b/src/api/routes/guilds/#guild_id/delete.ts
@@ -43,7 +43,7 @@ router.post( const guild = await Guild.findOneOrFail({ where: { id: guild_id }, - select: ["owner_id"], + select: { owner_id: true }, }); if (guild.owner_id !== req.user_id) throw new HTTPError("You are not the owner of this guild", 401); diff --git a/src/api/routes/guilds/#guild_id/messages/search.ts b/src/api/routes/guilds/#guild_id/messages/search.ts
index be00d5de..426d0dcf 100644 --- a/src/api/routes/guilds/#guild_id/messages/search.ts +++ b/src/api/routes/guilds/#guild_id/messages/search.ts
@@ -89,7 +89,7 @@ router.get( // get all channel IDs that this user can access const channels = await Channel.find({ where: { guild_id: req.params.guild_id }, - select: ["id"], + select: { id: true }, }); const ids = []; diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts
index ab61325e..e4dccb3e 100644 --- a/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts +++ b/src/api/routes/guilds/#guild_id/roles/#role_id/member-ids.ts
@@ -27,7 +27,7 @@ router.get("/", route({}), async (req: Request, res: Response) => { // TODO: Is this route really not paginated? const members = await Member.find({ - select: ["id"], + select: { id: true }, where: { roles: { id: role_id, diff --git a/src/api/routes/guilds/#guild_id/roles/member-counts.ts b/src/api/routes/guilds/#guild_id/roles/member-counts.ts
index d77149d5..0f3a12ce 100644 --- a/src/api/routes/guilds/#guild_id/roles/member-counts.ts +++ b/src/api/routes/guilds/#guild_id/roles/member-counts.ts
@@ -26,7 +26,7 @@ router.get("/", route({}), async (req: Request, res: Response) => { const { guild_id } = req.params; await Member.IsInGuildOrFail(req.user_id, guild_id); - const role_ids = await Role.find({ where: { guild_id }, select: ["id"] }); + const role_ids = await Role.find({ where: { guild_id }, select: { id: true } }); const counts: { [id: string]: number } = {}; for (const { id } of role_ids) { counts[id] = await Member.count({ where: { roles: { id }, guild_id } }); diff --git a/src/api/routes/oauth2/authorize.ts b/src/api/routes/oauth2/authorize.ts
index 4dea75c6..849e79b1 100644 --- a/src/api/routes/oauth2/authorize.ts +++ b/src/api/routes/oauth2/authorize.ts
@@ -75,7 +75,7 @@ router.get( id: req.user_id, bot: false, }, - select: ["id", "username", "avatar", "discriminator", "public_flags"], + select: { id: true, username: true, avatar: true, discriminator: true, public_flags: true }, }); const guilds = await Member.find({ @@ -83,10 +83,11 @@ router.get( id: req.user_id, }, relations: ["guild", "roles", "user"], - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - //@ts-ignore - // prettier-ignore - select: ["guild.id", "guild.name", "guild.icon", "guild.mfa_level", "guild.owner_id", "roles.id", "user.flags"], + select: { + guild: { id: true, name: true, icon: true, mfa_level: true, owner_id: true }, + roles: { id: true }, + user: { flags: true }, + }, }); const guildsWithPermissions = guilds.map((x) => { diff --git a/src/api/routes/safety-hub/@me/index.ts b/src/api/routes/safety-hub/@me/index.ts
index 7d0e7ff9..e5701292 100644 --- a/src/api/routes/safety-hub/@me/index.ts +++ b/src/api/routes/safety-hub/@me/index.ts
@@ -38,7 +38,7 @@ router.get( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); res.send({ diff --git a/src/api/routes/safety-hub/suspended/@me.ts b/src/api/routes/safety-hub/suspended/@me.ts
index 7d0e7ff9..e5701292 100644 --- a/src/api/routes/safety-hub/suspended/@me.ts +++ b/src/api/routes/safety-hub/suspended/@me.ts
@@ -38,7 +38,7 @@ router.get( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); res.send({ diff --git a/src/api/routes/teams.ts b/src/api/routes/teams.ts
index 090807d5..a9380f12 100644 --- a/src/api/routes/teams.ts +++ b/src/api/routes/teams.ts
@@ -64,7 +64,7 @@ router.post( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["mfa_enabled"], + select: { mfa_enabled: true }, }); if (!user.mfa_enabled) throw new HTTPError("You must enable MFA to create a team"); diff --git a/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts b/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts
index 8846efe4..a85348ae 100644 --- a/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts +++ b/src/api/routes/users/@me/connections/#connection_name/#connection_id/access-token.ts
@@ -55,7 +55,18 @@ router.get("/", route({}), async (req: Request, res: Response) => { external_id: connection_id, user_id: req.user_id, }, - select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "token_data", "friend_sync", "integrations"], + select: { + external_id: true, + type: true, + name: true, + verified: true, + visibility: true, + show_activity: true, + revoked: true, + token_data: true, + friend_sync: true, + integrations: true, + }, }); if (!connectedAccount) throw DiscordApiErrors.UNKNOWN_CONNECTION; if (connectedAccount.revoked) throw DiscordApiErrors.CONNECTION_REVOKED; diff --git a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts
index 111312ae..718c80c0 100644 --- a/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts +++ b/src/api/routes/users/@me/connections/#connection_name/#connection_id/index.ts
@@ -33,7 +33,7 @@ router.patch("/", route({ requestBody: "ConnectionUpdateSchema" }), async (req: external_id: connection_id, type: connection_name, }, - select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "friend_sync", "integrations"], + select: { external_id: true, type: true, name: true, verified: true, visibility: true, show_activity: true, revoked: true, friend_sync: true, integrations: true }, }); if (!connection) return DiscordApiErrors.UNKNOWN_CONNECTION; diff --git a/src/api/routes/users/@me/connections/index.ts b/src/api/routes/users/@me/connections/index.ts
index a2d8b82a..fe2fbba0 100644 --- a/src/api/routes/users/@me/connections/index.ts +++ b/src/api/routes/users/@me/connections/index.ts
@@ -27,7 +27,18 @@ router.get("/", route({}), async (req: Request, res: Response) => { where: { user_id: req.user_id, }, - select: ["external_id", "type", "name", "verified", "visibility", "show_activity", "revoked", "token_data", "friend_sync", "integrations"], + select: { + external_id: true, + type: true, + name: true, + verified: true, + visibility: true, + show_activity: true, + revoked: true, + token_data: true, + friend_sync: true, + integrations: true, + }, }); res.json(connections.map((x) => new ConnectedAccountDTO(x, true))); diff --git a/src/api/routes/users/@me/delete.ts b/src/api/routes/users/@me/delete.ts
index 668f7c19..749baf70 100644 --- a/src/api/routes/users/@me/delete.ts +++ b/src/api/routes/users/@me/delete.ts
@@ -40,7 +40,7 @@ router.post( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); //User object let correctpass = true; diff --git a/src/api/routes/users/@me/disable.ts b/src/api/routes/users/@me/disable.ts
index 95995e4b..e95ec457 100644 --- a/src/api/routes/users/@me/disable.ts +++ b/src/api/routes/users/@me/disable.ts
@@ -39,7 +39,7 @@ router.post( async (req: Request, res: Response) => { const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); //User object let correctpass = true; diff --git a/src/api/routes/users/@me/guilds.ts b/src/api/routes/users/@me/guilds.ts
index c06c39c4..89086562 100644 --- a/src/api/routes/users/@me/guilds.ts +++ b/src/api/routes/users/@me/guilds.ts
@@ -67,7 +67,7 @@ router.delete( const { guild_id } = req.params; const guild = await Guild.findOneOrFail({ where: { id: guild_id }, - select: ["owner_id"], + select: { owner_id: true }, }); if (!guild) throw new HTTPError("Guild doesn't exist", 404); diff --git a/src/api/routes/users/@me/guilds/#guild_id/settings.ts b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
index 16b64ec5..3aaf723e 100644 --- a/src/api/routes/users/@me/guilds/#guild_id/settings.ts +++ b/src/api/routes/users/@me/guilds/#guild_id/settings.ts
@@ -35,7 +35,7 @@ router.get( async (req: Request, res: Response) => { const user = await Member.findOneOrFail({ where: { id: req.user_id, guild_id: req.params.guild_id }, - select: ["settings"], + select: { settings: true }, }); return res.json(user.settings); }, @@ -66,7 +66,7 @@ router.patch( const user = await Member.findOneOrFail({ where: { id: req.user_id, guild_id: req.params.guild_id }, - select: ["settings"], + select: { settings: true }, }); OrmUtils.mergeDeep(user.settings || {}, body); Member.update({ id: req.user_id, guild_id: req.params.guild_id }, user); diff --git a/src/api/routes/users/@me/mfa/codes.ts b/src/api/routes/users/@me/mfa/codes.ts
index 2eb1a3e3..0b1b94da 100644 --- a/src/api/routes/users/@me/mfa/codes.ts +++ b/src/api/routes/users/@me/mfa/codes.ts
@@ -49,7 +49,7 @@ router.post( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data"], + select: { data: true }, }); if (!(await bcrypt.compare(password, user.data.hash || ""))) { diff --git a/src/api/routes/users/@me/mfa/totp/disable.ts b/src/api/routes/users/@me/mfa/totp/disable.ts
index 11c927e4..0b195601 100644 --- a/src/api/routes/users/@me/mfa/totp/disable.ts +++ b/src/api/routes/users/@me/mfa/totp/disable.ts
@@ -43,7 +43,7 @@ router.post( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["totp_secret"], + select: { totp_secret: true }, }); const backup = await BackupCode.findOne({ where: { code: body.code } }); diff --git a/src/api/routes/users/@me/mfa/totp/enable.ts b/src/api/routes/users/@me/mfa/totp/enable.ts
index a400c628..869f1573 100644 --- a/src/api/routes/users/@me/mfa/totp/enable.ts +++ b/src/api/routes/users/@me/mfa/totp/enable.ts
@@ -47,7 +47,7 @@ router.post( const user = await User.findOneOrFail({ where: { id: req.user_id }, - select: ["data", "email"], + select: { data: true, email: true }, }); // TODO: Are guests allowed to enable 2fa? diff --git a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
index 7bd29a57..50bf341c 100644 --- a/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts +++ b/src/api/routes/users/@me/mfa/webauthn/credentials/index.ts
@@ -80,7 +80,7 @@ router.post( where: { id: req.user_id, }, - select: ["data", "id", "disabled", "deleted", "totp_secret", "mfa_enabled", "username"], + select: { data: true, id: true, disabled: true, deleted: true, totp_secret: true, mfa_enabled: true, username: true }, relations: ["settings"], }); diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts
index 3f95daab..b796b29e 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -42,7 +42,7 @@ router.get( const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: ["relationships", "relationships.to"], - select: ["id", "relationships"], + select: { id: true, relationships: true }, }); const related_users = user.relationships.map((r) => r.toPublicRelationship()); diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index 6a2a75d3..6fb9f795 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -192,13 +192,13 @@ export async function onIdentify(this: WebSocket, data: Payload) { timePromise(() => Application.findOne({ where: { id: this.user_id }, - select: ["id", "flags"], + select: { id: true, flags: true }, }), ), timePromise(() => ReadState.find({ where: { user_id: this.user_id }, - select: ["id", "channel_id", "last_message_id", "last_pin_timestamp", "mention_count"], + select: { id: true, channel_id: true, last_message_id: true, last_pin_timestamp: true, mention_count: true }, }), ), timePromise(() => diff --git a/src/gateway/opcodes/PresenceUpdate.ts b/src/gateway/opcodes/PresenceUpdate.ts
index 2dfa8610..54ce3a89 100644 --- a/src/gateway/opcodes/PresenceUpdate.ts +++ b/src/gateway/opcodes/PresenceUpdate.ts
@@ -29,7 +29,7 @@ export async function onPresenceUpdate(this: WebSocket, { d }: Payload) { await Session.update({ session_id: this.session_id }, { status: presence.status, activities: presence.activities }); const session = await Session.findOneOrFail({ - select: ["client_status"], + select: { client_status: true }, where: { session_id: this.session_id }, }); diff --git a/src/util/entities/Member.ts b/src/util/entities/Member.ts
index 016424ec..b2a0fc89 100644 --- a/src/util/entities/Member.ts +++ b/src/util/entities/Member.ts
@@ -169,7 +169,7 @@ export class Member extends BaseClassWithoutId { static async removeFromGuild(user_id: string, guild_id: string) { const guild = await Guild.findOneOrFail({ - select: ["owner_id"], + select: { owner_id: true }, where: { id: guild_id }, }); if (guild.owner_id === user_id) throw new Error("The owner cannot be removed of the guild"); @@ -215,7 +215,7 @@ export class Member extends BaseClassWithoutId { }), Role.findOneOrFail({ where: { id: role_id, guild_id }, - select: ["id"], + select: { id: true }, }), ]); member.roles.push(Role.create({ id: role_id })); diff --git a/src/util/entities/User.ts b/src/util/entities/User.ts
index bc970c63..84471e0d 100644 --- a/src/util/entities/User.ts +++ b/src/util/entities/User.ts
@@ -217,7 +217,7 @@ export class User extends BaseClass { // First we need to figure out the currently highest discrimnator for the given username and then increment it const users = await User.find({ where: { username }, - select: ["discriminator"], + select: { discriminator: true }, }); const highestDiscriminator = Math.max(0, ...users.map((u) => Number(u.discriminator))); @@ -236,7 +236,7 @@ export class User extends BaseClass { const discriminator = Random.nextInt(1, 9999).toString().padStart(4, "0"); const exists = await User.findOne({ where: { discriminator, username: username }, - select: ["id"], + select: { id: true }, }); if (!exists) return discriminator; } diff --git a/src/util/util/Permissions.ts b/src/util/util/Permissions.ts
index 49bfb5fc..eb656f62 100644 --- a/src/util/util/Permissions.ts +++ b/src/util/util/Permissions.ts
@@ -256,7 +256,7 @@ export async function getPermission( let guild: Guild | undefined; const user = await User.findOneOrFail({ where: { id: user_id }, - select: ["id", "flags"], + select: { id: true, flags: true }, }); if (typeof channel_id === "string") {