summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorRory& <myrainbowdash949@gmail.com>2025-12-12 22:40:21 +0100
committerGitHub <noreply@github.com>2025-12-12 22:40:21 +0100
commita313f1037b37cc491a1d22bee4cb54114b5353b1 (patch)
tree384d4acf0e4058709bea4a0d6c1970d790b9a1e3 /src/api
parentRefactor: Replace getIpAddress with req.ip (diff)
parentMerge pull request #1436 from CyberL1/fix/config-stuff (diff)
downloadserver-ts-a313f1037b37cc491a1d22bee4cb54114b5353b1.tar.xz
Merge branch 'master' into refactor/remove-getIpAddress
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts2
-rw-r--r--src/api/routes/guilds/#guild_id/bans.ts1
-rw-r--r--src/api/routes/users/#user_id/profile.ts14
-rw-r--r--src/api/routes/webhooks/#webhook_id/#token/github.ts6
4 files changed, 7 insertions, 16 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 8790241d8..43c4984e0 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -548,7 +548,7 @@ router.delete( // TODO: handle other read state types if (body.read_state_type != ReadStateType.CHANNEL) return res.status(204).send(); - const readState = await ReadState.findOne({where: {channel_id}}); + const readState = await ReadState.findOne({ where: { channel_id, user_id: req.user_id } }); if (readState) { await readState.remove(); } diff --git a/src/api/routes/guilds/#guild_id/bans.ts b/src/api/routes/guilds/#guild_id/bans.ts
index 973f212dd..009cf3c8e 100644 --- a/src/api/routes/guilds/#guild_id/bans.ts +++ b/src/api/routes/guilds/#guild_id/bans.ts
@@ -215,7 +215,6 @@ router.put( const ban = Ban.create({ user_id: banned_user_id, guild_id: guild_id, - ip: req.ip, executor_id: req.user_id, reason: req.body.reason, // || otherwise empty }); diff --git a/src/api/routes/users/#user_id/profile.ts b/src/api/routes/users/#user_id/profile.ts
index 456f0cb74..a5ea3e9c4 100644 --- a/src/api/routes/users/#user_id/profile.ts +++ b/src/api/routes/users/#user_id/profile.ts
@@ -17,17 +17,7 @@ */ import { route } from "@spacebar/api"; -import { - Badge, - Config, - emitEvent, - FieldErrors, - handleFile, - Member, - Relationship, - User, - UserUpdateEvent, -} from "@spacebar/util"; +import { Badge, Config, emitEvent, FieldErrors, handleFile, Member, Relationship, User, UserUpdateEvent } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { In } from "typeorm"; import { PrivateUserProjection, PublicUser, PublicUserProjection, RelationshipType, UserProfileModifySchema } from "@spacebar/schemas"; @@ -127,7 +117,7 @@ router.get("/", route({ responses: { 200: { body: "UserProfileResponse" } } }), premium_type: user.premium_type, profile_themes_experiment_bucket: 4, // TODO: This doesn't make it available, for some reason? user_profile: userProfile, - guild_member: guild_member?.toPublicMember(), + guild_member: { ...guild_member?.toPublicMember(), user: user.toPublicUser() }, guild_member_profile: guild_id && guildMemberProfile, badges: badges.filter((x) => user.badge_ids?.includes(x.id)), }); diff --git a/src/api/routes/webhooks/#webhook_id/#token/github.ts b/src/api/routes/webhooks/#webhook_id/#token/github.ts
index 419b8d23a..ef47c1d9e 100644 --- a/src/api/routes/webhooks/#webhook_id/#token/github.ts +++ b/src/api/routes/webhooks/#webhook_id/#token/github.ts
@@ -168,7 +168,9 @@ const parseGitHubWebhook = (req: Request, res: Response, next: NextFunction) => ]; if (req.body.action === "opened") { - discordPayload.embeds[0].description = req.body.pull_request.body.length > 500 ? `${req.body.pull_request.body.slice(0, 497)}...` : req.body.pull_request.body; + if (req.body.pull_request.body != null) { + discordPayload.embeds[0].description = req.body.pull_request.body.length > 500 ? `${req.body.pull_request.body.slice(0, 497)}...` : req.body.pull_request.body; + } discordPayload.embeds[0].color = 38912; } break; @@ -241,7 +243,7 @@ const parseGitHubWebhook = (req: Request, res: Response, next: NextFunction) => url: req.body.sender.html_url, }, title: `[${req.body.repository.name}:${req.body.ref.slice(11)}] ${req.body.commits.length} new commit${req.body.commits.length > 1 ? "s" : ""}`, - url: req.body.head_commit.url, + url: req.body.commits.length > 1 ? req.body.compare : req.body.head_commit.url, description: req.body.commits .slice(0, 5) // Discord only shows 5 first commits .map(