jschan - Anonymous imageboard software. Classic look, modern features and feel. Works without JavaScript and supports Tor, I2P, Lokinet, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

101 lines
1.8 KiB

'use strict';
module.exports = async(db, redis) => {
console.log('changing post/report/ban ip type storage format');
await db.collection('posts').updateMany({
/* Make sure they all existing ones at least have a type
in case the site uses "dont store raw ips" */
}, {
'$set': {
'ip.type': 0,
}
});
await db.collection('posts').updateMany({
'ip.raw': /^([0-9]+(\.|$)){4}/
}, [{
'$set': {
'ip.type': 0,
'ip.cloak': {
$concat: ['$ip.cloak', '4']
}
}
}]);
await db.collection('posts').updateMany({
'ip.raw': /:/
}, [{
'$set': {
'ip.type': 1,
'ip.cloak': {
$concat: ['$ip.cloak', '6']
}
}
}]);
await db.collection('posts').updateMany({
'ip.cloak': /PRUNED$/
}, {
'$set': {
'ip.type': 3,
}
});
await db.collection('posts').updateMany({
'ip.cloak': /BP$/
}, {
'$set': {
'ip.type': 2,
}
});
await db.collection('posts').updateMany({}, {
'$set': {
reports: [],
globalreports: [],
}
});
await db.collection('bans').updateMany({
/* Make sure they all existing ones at least have a type
in case the site uses "dont store raw ips" */
}, {
'$set': {
'ip.type': 0,
}
});
await db.collection('bans').updateMany({
'ip.raw': /^([0-9]+(\.|$)){4}/
}, [{
'$set': {
'ip.type': 0,
'ip.cloak': {
$concat: ['$ip.cloak', '4']
}
}
}]);
await db.collection('bans').updateMany({
'ip.raw': /:/
}, [{
'$set': {
'ip.type': 1,
'ip.cloak': {
$concat: ['$ip.cloak', '6']
}
}
}]);
await db.collection('bans').updateMany({
'ip.cloak': /PRUNED$/
}, {
'$set': {
'ip.type': 3,
}
});
await db.collection('bans').updateMany({
'ip.cloak': /BP$/
}, {
'$set': {
'ip.type': 2,
}
});
console.log('Clearing globalsettings cache');
await redis.deletePattern('globalsettings');
};