Bugfix & improve bans from filter to remove unnecessary queyr, use insertedId from insertOne instead of fetching again

merge-requests/208/head
fatchan 4 years ago
parent 9cbf198772
commit a517a3659c
  1. 7
      models/forms/editpost.js
  2. 9
      models/forms/makepost.js

@ -52,6 +52,7 @@ todo: handle some more situations
'single': res.locals.ip.single,
'raw': res.locals.ip.raw,
},
'subnet': '/32',
'reason': 'global word filter auto ban',
'board': null,
'posts': null,
@ -61,10 +62,10 @@ todo: handle some more situations
'allowAppeal': true, //should i make this configurable if appealable?
'seen': false
};
await Bans.insertOne(ban);
const bans = await Bans.find(res.locals.ip.single, banBoard); //need to query db so it has _id field for appeal checkmark
const insertedResult = await Bans.insertOne(ban);
ban._id = insertedResult.insertedId;
return res.status(403).render('ban', {
bans: bans
bans: [ban]
});
}
}

@ -135,8 +135,9 @@ module.exports = async (req, res, next) => {
const ban = {
'ip': {
'single': res.locals.ip.single,
'raw': res.local.ip.raw,
'raw': res.locals.ip.raw,
},
'subnet': '/32',
'reason': `${hitGlobalFilter ? 'global ' :''}word filter auto ban`,
'board': banBoard,
'posts': null,
@ -146,10 +147,10 @@ module.exports = async (req, res, next) => {
'allowAppeal': true, //should i make this configurable if appealable?
'seen': false
};
await Bans.insertOne(ban);
const bans = await Bans.find(res.locals.ip.single, banBoard); //need to query db so it has _id field for appeal checkmark
const insertedResult = await Bans.insertOne(ban);
ban._id = insertedResult.insertedId;
return res.status(403).render('ban', {
bans: bans
bans: [ban]
});
}
}

Loading…
Cancel
Save