summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-17 11:28:29 +0100
committerRory& <root@rory.gay>2025-12-17 11:28:29 +0100
commit915000ee40784254b93d85d9a074b6b4e0ea52ec (patch)
treeefa8c69e371dbc7f7f330c137cf51f08128ed8c5 /src/api
parentMerge remote-tracking branch 'mathium05/greetFix' (diff)
parentRun ESLint (diff)
downloadserver-ts-915000ee40784254b93d85d9a074b6b4e0ea52ec.tar.xz
Merge remote-tracking branch 'DEVTomatoCake/fix/getPublicUser-no-defaults'
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/invites.ts8
-rw-r--r--src/api/routes/guilds/#guild_id/bans.ts6
-rw-r--r--src/api/routes/guilds/#guild_id/bulk-ban.ts2
-rw-r--r--src/api/routes/users/#user_id/profile.ts5
-rw-r--r--src/api/util/handlers/Message.ts4
5 files changed, 15 insertions, 10 deletions
diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts

index 808f0f8c..45b7d790 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/>. */ @@ -72,7 +72,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/guilds/#guild_id/bans.ts b/src/api/routes/guilds/#guild_id/bans.ts
index cf043b7e..2bd28ace 100644 --- a/src/api/routes/guilds/#guild_id/bans.ts +++ b/src/api/routes/guilds/#guild_id/bans.ts
@@ -20,7 +20,7 @@ import { route } from "@spacebar/api"; import { Ban, DiscordApiErrors, GuildBanAddEvent, GuildBanRemoveEvent, Member, User, emitEvent } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; -import { APIBansArray, BanCreateSchema, BanRegistrySchema, GuildBansResponse } from "@spacebar/schemas"; +import { APIBansArray, BanCreateSchema, BanRegistrySchema, GuildBansResponse, PublicUser } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); @@ -43,7 +43,7 @@ router.get( const { guild_id } = req.params; let bans = await Ban.find({ where: { guild_id: guild_id } }); - const promisesToAwait: Promise<User>[] = []; + const promisesToAwait: Promise<PublicUser>[] = []; const bansObj: APIBansArray = []; bans = bans.filter((ban) => ban.user_id !== ban.executor_id); // pretend self-bans don't exist to prevent victim chasing @@ -236,7 +236,7 @@ router.put( event: "GUILD_BAN_ADD", data: { guild_id: guild_id, - user: banned_user.toPublicUser(), + user: banned_user, delete_message_secs: Math.floor(deleteMessagesMs / 1000), }, guild_id: guild_id, diff --git a/src/api/routes/guilds/#guild_id/bulk-ban.ts b/src/api/routes/guilds/#guild_id/bulk-ban.ts
index 004c2ab2..41e14ebd 100644 --- a/src/api/routes/guilds/#guild_id/bulk-ban.ts +++ b/src/api/routes/guilds/#guild_id/bulk-ban.ts
@@ -94,7 +94,7 @@ router.post( event: "GUILD_BAN_ADD", data: { guild_id: guild_id, - user: banned_user.toPublicUser(), + user: banned_user, }, guild_id: guild_id, } as GuildBanAddEvent), diff --git a/src/api/routes/users/#user_id/profile.ts b/src/api/routes/users/#user_id/profile.ts
index bcd59cd1..b100ac35 100644 --- a/src/api/routes/users/#user_id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts
@@ -29,7 +29,10 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), const { guild_id, with_mutual_guilds, with_mutual_friends, with_mutual_friends_count } = req.query; - const user = await User.getPublicUser(req.params.user_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 65583f53..915fe292 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts
@@ -158,7 +158,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"); }