summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2024-07-28 20:51:16 +1000
committerGitHub <noreply@github.com>2024-07-28 20:51:16 +1000
commita8acb554ad4e52eb9f85968eb4f590a2adac01a5 (patch)
tree173ae43b2022bb4d1733ed1e556c9a88e3e65a82 /src/api
parentUpdated the openapi schema (diff)
parentprettier .-. (diff)
downloadserver-ts-a8acb554ad4e52eb9f85968eb4f590a2adac01a5.tar.xz
Merge branch 'master' into master
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts14
-rw-r--r--src/api/routes/users/@me/index.ts11
2 files changed, 20 insertions, 5 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index 645c6db2..d4635b1d 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] : []; } diff --git a/src/api/routes/users/@me/index.ts b/src/api/routes/users/@me/index.ts
index ad11a428..cddc3a08 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) {