property name fixes/change, category -> type, type -> range, now they reflect more what they actually are
bantable updated, bit cleaner mixin
bantables now more compact, will overflow (with scroll) and no text wrap
close #446
merge-requests/341/head
Thomas Lynch 2 years ago
parent 578578af0f
commit 206dd3bc32
  1. 6
      db/bans.js
  2. 13
      gulp/res/css/style.css
  3. 38
      migrations/0.6.0.js
  4. 18
      models/forms/banposter.js
  5. 4
      models/forms/editpost.js
  6. 4
      models/forms/makepost.js
  7. 6
      views/includes/bantable.pug
  8. 6
      views/mixins/ban.pug

@ -41,9 +41,9 @@ module.exports = {
},
'board': board,
//bypass or pruned IP bans aren't upgraded, duh!
'category': 0,
'type': 0,
//dont allow half -> quarter
'type': {
'range': {
'$lt': upgradeType
}
}
@ -51,7 +51,7 @@ module.exports = {
'$project': {
'_id': 1,
'board': 1,
'type': {
'range': {
//mongoloidDB
'$literal': upgradeType,
},

@ -1338,11 +1338,14 @@ hr + .thread {
margin-top: -5px;
}
.scrolltable {
max-height: 160px;
overflow-y: auto;
overflow-x: hidden;
border: 1px solid var(--box-border-color);
.bantable {
max-width: unset;
word-break: keep-all;
white-space: nowrap;
}
.bantable td, .bantable th {
padding: 5px 10px;
}
tr:nth-child(odd) {

@ -1,26 +1,56 @@
'use strict';
module.exports = async(db, redis) => {
console.log('Addjusting bans to categorise between normal/bypass/pruned, required for ban upgrading capabilities');
console.log('rename ban type -> range');
await db.collection('bans').updateMany({}, {
'$rename': {
'type': 'range',
},
});
console.log('change ban range from strings to number');
await db.collection('bans').updateMany({
'range': 'single'
}, {
'$set': {
'range': 0,
},
});
await db.collection('bans').updateMany({
'range': 'qrange'
}, {
'$set': {
'range': 1,
},
});
await db.collection('bans').updateMany({
'range': 'hrange'
}, {
'$set': {
'range': 2,
},
});
console.log('set new ban.type based on ip/bypass/pruned');
await db.collection('bans').updateMany({
'ip.cloak': /\.IP$/
}, {
'$set':{
'category': 0,
'type': 0,
},
});
await db.collection('bans').updateMany({
'ip.cloak': /\.BP$/
}, {
'$set':{
'category': 1,
'type': 1,
},
});
await db.collection('bans').updateMany({
'ip.cloak': /\.PRUNED$/
}, {
'$set':{
'category': 2,
'type': 2,
},
});
};

@ -23,33 +23,33 @@ module.exports = async (req, res, next) => {
return acc;
}, {});
for (let ip in ipPosts) {
const banCategory = ip.endsWith('.IP') ? 0 :
const banType = ip.endsWith('.IP') ? 0 :
ip.endsWith('.BP') ? 1 :
2;
/* should we at some point filter these to not bother banning pruned ips,
and/or not range banning bypasses (since it does nothing)? */
const thisIpPosts = ipPosts[ip];
let type = 0;
let banRange = 0;
let banIp = {
cloak: thisIpPosts[0].ip.cloak,
raw: thisIpPosts[0].ip.raw,
};
if (req.body.ban_h) {
type = 2;
banRange = 2;
banIp.cloak = thisIpPosts[0].ip.cloak
.split('.')
.slice(0,1)
.join('.');
} else if (req.body.ban_q) {
type = 1;
banRange = 1;
banIp.cloak = thisIpPosts[0].ip.cloak
.split('.')
.slice(0,2)
.join('.');
}
bans.push({
type,
'category': banCategory,
'range': banRange,
'type': banType,
'ip': banIp,
'reason': banReason,
'board': banBoard,
@ -87,9 +87,13 @@ module.exports = async (req, res, next) => {
}
ips = ips.filter(n => n);
[...new Set(ips)].forEach(ip => {
const banType = ip.endsWith('.IP') ? 0 :
ip.endsWith('.BP') ? 1 :
2;
bans.push({
'type': banType,
'range': 0,
'ip': ip,
'type': 0,
'reason': banReason,
'board': banBoard,
'posts': null,

@ -56,8 +56,8 @@ todo: handle some more situations
'cloak': res.locals.ip.cloak,
'raw': res.locals.ip.raw,
},
'category': res.locals.anonymizer ? 1 : 0,
'type': 0,
'type': res.locals.anonymizer ? 1 : 0,
'range': 0,
'reason': 'global word filter auto ban',
'board': null,
'posts': null,

@ -150,8 +150,8 @@ ${res.locals.numFiles > 0 ? req.files.file.map(f => f.name+'|'+(f.phash || '')).
'cloak': res.locals.ip.cloak,
'raw': res.locals.ip.raw,
},
'category': res.locals.anonymizer ? 1 : 0, //no 2, because that only happens during pruning
'type': 0,
'type': res.locals.anonymizer ? 1 : 0,
'range': 0,
'reason': `${hitGlobalFilter ? 'global ' :''}word filter auto ban`,
'board': banBoard,
'posts': null,

@ -1,12 +1,12 @@
.table-container.mv-10.text-center.horscroll
table.fw
table.bantable
tr
th
th Board
th Reason
th IP
th Category
th IP/ID
th Type
th Range
th Issuer
th Issue Date
th Expiry

@ -14,9 +14,9 @@ mixin ban(ban, banpage)
if viewRawIp === true
td #{ip}
else
td #{ip}#{ban.type === 'hrange' ? '.*.*' : (ban.type === 'qrange' ? '.*' : '')}
td #{ban.category === 0 ? 'IP' : ban.category === 1 ? 'Bypass' : 'Pruned IP'}
td #{ban.type === 0 ? 'Single' : ban.type === 1 ? 'Quarter' : 'Half'}
td #{ip}#{'.*'.repeat(ban.range)}
td #{ban.type === 0 ? 'IP' : ban.type === 1 ? 'Bypass' : 'Pruned IP'}
td #{ban.range === 0 ? 'Single' : ban.range === 1 ? 'Quarter' : 'Half'}
td #{(!banpage || ban.showUser === true) ? ban.issuer : 'Hidden User'}
- const banDate = new Date(ban.date);
td: time.right.reltime(datetime=banDate.toISOString()) #{banDate.toLocaleString(undefined, {hourCycle:'h23'})}

Loading…
Cancel
Save