Skip to content

Commit

Permalink
Merge branch 'master' into fix/username-change-no-password
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberL1 authored Jul 28, 2024
2 parents b641f1d + 481cf38 commit 99a20a3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/api/routes/channels/#channel_id/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] : [];
}
Expand Down

0 comments on commit 99a20a3

Please sign in to comment.