Merge branch 'master' into feat/webhooks-3

This commit is contained in:
TomatoCake
2024-08-08 18:03:13 +02:00
9 changed files with 117 additions and 14 deletions

View File

@@ -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);

View File

@@ -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,

View File

@@ -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) {