summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-08 18:03:13 +0200
committerTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-08 18:03:13 +0200
commit4ca79adcaeadb63113789a699c8f2eadb9ffd55c (patch)
treed426e44431b6bc09c9292a525489424249ef034d /src/api
parentPrettier (diff)
parentMerge pull request #1156 from DEVTomatoCake/fix/messages-before-param (diff)
downloadserver-ts-4ca79adcaeadb63113789a699c8f2eadb9ffd55c.tar.xz
Merge branch 'master' into feat/webhooks-3
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts15
-rw-r--r--src/api/routes/guilds/#guild_id/bulk-ban.ts4
-rw-r--r--src/api/routes/users/@me/index.ts11
3 files changed, 24 insertions, 6 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 645c6db23..db46aff71 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -130,19 +130,25 @@ router.get( query.take = Math.floor(limit / 2); if (query.take != 0) { const [right, left] = await Promise.all([ - Message.find({ ...query, where: { id: LessThan(around) } }), Message.find({ ...query, - where: { id: MoreThanOrEqual(around) }, + where: { channel_id, id: LessThan(around) }, + }), + Message.find({ + ...query, + where: { channel_id, id: MoreThanOrEqual(around) }, + order: { timestamp: "ASC" }, }), ]); left.push(...right); - messages = left; + messages = left.sort( + (a, b) => a.timestamp.getTime() - b.timestamp.getTime(), + ); } else { query.take = 1; const message = await Message.findOne({ ...query, - where: { id: around }, + where: { channel_id, id: around }, }); messages = message ? [message] : []; } @@ -151,6 +157,7 @@ router.get( if (BigInt(after) > BigInt(Snowflake.generate())) return res.status(422); query.where.id = MoreThan(after); + query.order = { timestamp: "ASC" }; } else if (before) { if (BigInt(before) > BigInt(Snowflake.generate())) return res.status(422); diff --git a/src/api/routes/guilds/#guild_id/bulk-ban.ts b/src/api/routes/guilds/#guild_id/bulk-ban.ts
index f544103a5..e5f7a0d8e 100644 --- a/src/api/routes/guilds/#guild_id/bulk-ban.ts +++ b/src/api/routes/guilds/#guild_id/bulk-ban.ts
@@ -27,6 +27,7 @@ import { } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; +import { Config } from "@spacebar/util"; const router: Router = Router(); @@ -52,7 +53,8 @@ router.post( const userIds: Array<string> = req.body.user_ids; if (!userIds) throw new HTTPError("The user_ids array is missing", 400); - if (userIds.length > 200) + + if (userIds.length > Config.get().limits.guild.maxBulkBanUsers) throw new HTTPError( "The user_ids array must be between 1 and 200 in length", 400, diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts
index ad11a4281..cddc3a087 100644 --- a/src/api/routes/users/@me/index.ts +++ b/src/api/routes/users/@me/index.ts
@@ -120,7 +120,7 @@ router.patch( if (!body.password) throw FieldErrors({ password: { - message: req.t("auth:register.INVALID_PASSWORD"), + message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD", }, }); @@ -160,6 +160,15 @@ router.patch( }, }); } + + if (!body.password) { + throw FieldErrors({ + password: { + message: req.t("auth:login.INVALID_PASSWORD"), + code: "INVALID_PASSWORD", + }, + }); + } } if (body.discriminator) {