add column in ban table to show if a ban has been viewed

merge-requests/208/head
fatchan 5 years ago
parent 2715626fcc
commit 957cc087c8
  1. 14
      db/bans.js
  2. 2
      helpers/checks/bancheck.js
  3. 7
      models/forms/banposter.js
  4. 6
      models/forms/makepost.js
  5. 1
      views/includes/bantable.pug
  6. 5
      views/mixins/ban.pug

@ -17,6 +17,18 @@ module.exports = {
}).toArray();
},
markSeen: (ids) => {
return db.updateMany({
'_id': {
'$in': ids
}
}, {
'$set': {
'seen': true,
}
});
},
appeal: (ip, ids, appeal) => {
return db.updateMany({
'_id': {
@ -24,7 +36,7 @@ module.exports = {
},
'ip': ip,
'allowAppeal': true,
'appeal': null
'appeal': null
}, {
'$set': {
'appeal': appeal,

@ -12,6 +12,8 @@ module.exports = async (req, res, next) => {
if (globalBans.length > 0 || (res.locals.permLevel >= 4 && globalBans.length !== bans.length)) {
//board staff bypass bans on their own board, but not global bans
const allowAppeal = bans.filter(ban => ban.allowAppeal === true && ban.appeal === null).length > 0;
const unseenBans = bans.filter(b => !b.seen).map(b._id);
await Bans.markSeen(unseenBans); //mark bans as seen
return res.status(403).render('ban', {
bans: bans,
allowAppeal

@ -31,7 +31,8 @@ module.exports = async (req, res, next) => {
'date': banDate,
'expireAt': banExpiry,
allowAppeal,
'appeal': null
'appeal': null,
'seen': false,
});
}
}
@ -65,7 +66,8 @@ module.exports = async (req, res, next) => {
'date': banDate,
'expireAt': banExpiry,
allowAppeal,
'appeal': null
'appeal': null,
'seen': false
});
});
});
@ -78,6 +80,7 @@ module.exports = async (req, res, next) => {
};
if ((req.body.ban || req.body.global_ban ) && req.body.ban_reason) {
res.locals.actions.numBuild++;//there was a ban reason, so we may need to rebuild some pages, since banning is usually not a building action
query['action'] = '$set';
query['query'] = {
'banmessage': req.body.ban_reason

@ -119,10 +119,12 @@ module.exports = async (req, res, next) => {
'posts': null,
'issuer': 'system', //what should i call this
'date': banDate,
'expireAt': banExpiry
'expireAt': banExpiry,
'allowAppeal': true, //should i make this configurable if appealable?
'seen': false
};
await Bans.insertOne(ban);
const bans = await Bans.find(res.locals.ip, res.locals.board._id);
const bans = await Bans.find(res.locals.ip, res.locals.board._id); //need to query db so it has _id field for unban checkmark
return res.status(403).render('ban', {
bans: bans
});

@ -9,5 +9,6 @@
th Issue Date
th Expiry
th Post(s)
th Seen?
th Appealable?
th Appeal

@ -22,6 +22,11 @@ mixin ban(ban, banpage)
+post(p, false, false, false, true)
else
Posts not shown
td
if ban.seen
| ✓
else
| ⨯
td
if ban.allowAppeal
| ✓

Loading…
Cancel
Save