🐛 fix bigint id in message route

This commit is contained in:
Flam3rboy 2021-04-06 18:07:18 +02:00
parent 7089287016
commit fbeb7ce8f8
2 changed files with 7 additions and 3 deletions

4
package-lock.json generated
View File

@ -4614,7 +4614,7 @@
}, },
"node_modules/fosscord-server-util": { "node_modules/fosscord-server-util": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#770b07400e282c5e06fe0638d791139e3984f50f", "resolved": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3205dc6f6080422b8d2f727fe9e4573b493ffbb1",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
@ -16151,7 +16151,7 @@
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
}, },
"fosscord-server-util": { "fosscord-server-util": {
"version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#770b07400e282c5e06fe0638d791139e3984f50f", "version": "git+ssh://git@github.com/fosscord/fosscord-server-util.git#3205dc6f6080422b8d2f727fe9e4573b493ffbb1",
"from": "fosscord-server-util@github:fosscord/fosscord-server-util", "from": "fosscord-server-util@github:fosscord/fosscord-server-util",
"requires": { "requires": {
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",

View File

@ -60,7 +60,11 @@ router.get("/", async (req, res) => {
var query: any; var query: any;
if (after) query = MessageModel.find({ channel_id, id: { $gt: after } }); if (after) query = MessageModel.find({ channel_id, id: { $gt: after } });
else if (before) query = MessageModel.find({ channel_id, id: { $lt: before } }); else if (before) query = MessageModel.find({ channel_id, id: { $lt: before } });
else if (around) query = MessageModel.find({ channel_id, id: { $gt: around - halfLimit, $lt: around + halfLimit } }); else if (around)
query = MessageModel.find({
channel_id,
id: { $gt: (BigInt(around) - BigInt(halfLimit)).toString(), $lt: (BigInt(around) + BigInt(halfLimit)).toString() },
});
else { else {
query = MessageModel.find({ channel_id }).sort({ id: -1 }); query = MessageModel.find({ channel_id }).sort({ id: -1 });
} }