mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-25 19:52:36 +01:00
Fix regression of 5f22faa57b
This commit is contained in:
parent
5f22faa57b
commit
08f17f88e7
@ -119,25 +119,26 @@ router.get(
|
||||
};
|
||||
|
||||
let messages: Message[];
|
||||
if (after) {
|
||||
if (BigInt(after) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
query.where.id = MoreThan(after);
|
||||
messages = await Message.find(query);
|
||||
} else if (before) {
|
||||
if (BigInt(before) < BigInt(req.params.channel_id))
|
||||
return res.status(422);
|
||||
query.where.id = LessThan(before);
|
||||
messages = await Message.find(query);
|
||||
} else if (around) {
|
||||
|
||||
if (around) {
|
||||
query.take = Math.floor(limit / 2);
|
||||
query.where.id = LessThan(around);
|
||||
const messages_before = await Message.find(query);
|
||||
query.where.id = MoreThan(around);
|
||||
const messages_after = await Message.find(query);
|
||||
messages = messages_before.concat(messages_after);
|
||||
const [right, left] = await Promise.all([
|
||||
Message.find({ ...query, where: { id: LessThan(around) } }),
|
||||
Message.find({ ...query, where: { id: MoreThan(around) } }),
|
||||
]);
|
||||
messages = right.concat(left);
|
||||
} else {
|
||||
throw new HTTPError("after, around or before must be present", 422);
|
||||
if (after) {
|
||||
if (BigInt(after) > BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
query.where.id = MoreThan(after);
|
||||
} else if (before) {
|
||||
if (BigInt(before) < BigInt(Snowflake.generate()))
|
||||
return res.status(422);
|
||||
query.where.id = LessThan(before);
|
||||
}
|
||||
|
||||
messages = await Message.find(query);
|
||||
}
|
||||
|
||||
const endpoint = Config.get().cdn.endpointPublic;
|
||||
|
Loading…
Reference in New Issue
Block a user