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.
 
 
 
 
 

44 lines
1.3 KiB

'use strict';
const { debugLogs } = require(__dirname+'/../../configs/secrets.js')
, config = require(__dirname+'/../../lib/misc/config.js')
, { Boards } = require(__dirname+'/../../db/')
, timeUtils = require(__dirname+'/../../lib/converter/timeutils.js')
, deleteBoard = require(__dirname+'/../../models/forms/deleteboard.js');
module.exports = {
func: async () => {
if (config.get.abandonedBoardAction === 0) {
return;
}
const abandonedBoards = await Boards.getAbandoned(config.get.abandonedBoardAction);
if (abandonedBoards.length === 0) {
return;
}
if (config.get.abandonedBoardAction <= 2) {
debugLogs && console.log(`Locking${config.get.abandonedBoardAction === 2 ? '+Unlisting' : ''} ${abandonedBoards.length} abandoned boards.`);
const abandonedURIs = abandonedBoards.map(b => b._id);
Boards.unlistMany(abandonedURIs);
} else { //must be 2
//run delete board model for each
debugLogs && console.log(`Deleting ${abandonedBoards.length} abandoned boards.`);
for (let board of abandonedBoards) {
try {
await deleteBoard(board._id, board);
} catch (err) {
debugLogs && console.log('Error deleting abandoned board:', err);
}
}
}
},
interval: timeUtils.DAY,
immediate: true,
condition: 'abandonedBoardAction'
};