summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-09-01 18:44:35 +0200
committerTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-09-01 18:44:35 +0200
commit269d4eecdd3c1ff053b2749ddc186285f1a17a16 (patch)
tree437ab41eccfad253b97558b4824b1cbb8775908a /src/api
parentMerge pull request #1207 from DEVTomatoCake/fix/more-application-properties-m... (diff)
downloadserver-ts-269d4eecdd3c1ff053b2749ddc186285f1a17a16.tar.xz
Stop returning defaults when using getPublicUser()
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts8
-rw-r--r--src/api/routes/users/#id/profile.ts5
-rw-r--r--src/api/util/handlers/Message.ts4
3 files changed, 11 insertions, 6 deletions
diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts

index ae32e80d..3bb37195 100644 --- a/src/api/routes/channels/#channel_id/invites.ts +++ b/src/api/routes/channels/#channel_id/invites.ts
@@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ @@ -84,7 +84,7 @@ router.post( }).save(); const data = invite.toJSON(); - data.inviter = (await User.getPublicUser(req.user_id)).toPublicUser(); + data.inviter = await User.getPublicUser(req.user_id); data.guild = await Guild.findOne({ where: { id: guild_id } }); data.channel = channel; diff --git a/src/api/routes/users/#id/profile.ts b/src/api/routes/users/#id/profile.ts
index 44271cad..6d727dcf 100644 --- a/src/api/routes/users/#id/profile.ts +++ b/src/api/routes/users/#id/profile.ts
@@ -41,7 +41,10 @@ router.get( const { guild_id, with_mutual_guilds } = req.query; - const user = await User.getPublicUser(req.params.id, { + const user = await User.findOneOrFail({ + where: { + id: req.params.id, + }, relations: ["connected_accounts"], }); diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts
index f037417a..25693200 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -87,7 +87,9 @@ export async function handleMessage(opts: MessageOptions): Promise<Message> { } if (opts.author_id) { - message.author = await User.getPublicUser(opts.author_id); + message.author = await User.findOneOrFail({ + where: { id: opts.author_id }, + }); const rights = await getRights(opts.author_id); rights.hasThrow("SEND_MESSAGES"); }