From 3ab0a271c44328bba40984bf99a306ca13a1464d Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 1 Jul 2022 20:35:39 +1000 Subject: [PATCH 1/5] Inactive accounts handling schedule, globalsettings for it and migration. Plus the same for abandoned boards handling, just still TODO the schedule. ref #418 --- configs/template.js.example | 8 +++ controllers/forms/globalsettings.js | 7 +- db/accounts.js | 26 ++++++- migrations/0.8.0.js | 16 +++++ models/forms/changeglobalsettings.js | 3 + package.json | 2 +- schedules/tasks/abandonedboards.js | 26 +++++++ schedules/tasks/inactiveaccounts.js | 100 +++++++++++++++++++++++++++ views/pages/globalmanagesettings.pug | 16 +++++ 9 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 migrations/0.8.0.js create mode 100644 schedules/tasks/abandonedboards.js create mode 100644 schedules/tasks/inactiveaccounts.js diff --git a/configs/template.js.example b/configs/template.js.example index 51a48a56..eac6fe77 100644 --- a/configs/template.js.example +++ b/configs/template.js.example @@ -175,6 +175,14 @@ module.exports = { //how many of the most recent newsposts to show on the homepage maxRecentNews: 5, + //time for an account to be considered inactive + inactiveAccountTime: 7889400000, + //action for inactive accounts: nothing, forfeit staff positions, delete account + inactiveAccountAction: 0, + + //action for handling abandoned boards (no board owner): nothing, lock, lock + unlist, delete board + abandonedBoardAction: 0, + /* filter filenames on posts and banners false=no filtering true=allow only A-Za-z0-9_- diff --git a/controllers/forms/globalsettings.js b/controllers/forms/globalsettings.js index 2a6e33f9..b7dd2c5e 100644 --- a/controllers/forms/globalsettings.js +++ b/controllers/forms/globalsettings.js @@ -11,9 +11,9 @@ const changeGlobalSettings = require(__dirname+'/../../models/forms/changeglobal module.exports = { paramConverter: paramConverter({ - timeFields: ['ban_duration', 'board_defaults_filter_ban_duration', 'default_ban_duration', 'block_bypass_expire_after_time', 'dnsbl_cache_time', 'board_defaults_delete_protection_age'], + timeFields: ['inactive_account_time', 'ban_duration', 'board_defaults_filter_ban_duration', 'default_ban_duration', 'block_bypass_expire_after_time', 'dnsbl_cache_time', 'board_defaults_delete_protection_age'], trimFields: ['allowed_hosts', 'dnsbl_blacklists', 'other_mime_types', 'highlight_options_language_subset', 'global_limits_custom_css_filters', 'board_defaults_filters', 'filters', 'archive_links', 'reverse_links'], - numberFields: ['filter_mode', 'auth_level', + numberFields: ['inactive_account_action', 'abandoned_board_action','filter_mode', 'auth_level', 'captcha_options_generate_limit', 'captcha_options_grid_size', 'captcha_options_grid_image_size', 'captcha_options_num_distorts_min', 'captcha_options_num_distorts_max', 'captcha_options_distortion', 'captcha_options_grid_icon_y_offset', 'flood_timers_same_content_same_ip', 'flood_timers_same_content_any_ip', 'flood_timers_any_content_same_ip', 'block_bypass_expire_after_uses', 'rate_limit_cost_captcha', 'rate_limit_cost_board_settings', 'rate_limit_cost_edit_post', @@ -68,6 +68,9 @@ module.exports = { } return false; }, expected: true, error: 'Invalid reverse image search links URL format, must be a link containing %s where the url param belongs.' }, + { result: numberBody(req.body.inactive_account_time), expected: true, error: 'Invalid inactive account time' }, + { result: numberBody(req.body.inactive_account_action, 0, 3), expected: true, error: 'Inactive account action must be a number from 0-3' }, + { result: numberBody(req.body.abandoned_board_action, 0, 2), expected: true, error: 'Abandoned board action must be a number from 0-2' }, { result: lengthBody(req.body.global_announcement, 0, 10000), expected: false, error: 'Global announcement must not exceed 10000 characters' }, { result: lengthBody(req.body.filters, 0, 50000), expected: false, error: 'Filter text cannot exceed 50000 characters' }, { result: numberBody(req.body.filter_mode, 0, 2), expected: true, error: 'Filter mode must be a number from 0-2' }, diff --git a/db/accounts.js b/db/accounts.js index 56a17710..9ba09535 100644 --- a/db/accounts.js +++ b/db/accounts.js @@ -3,7 +3,8 @@ const Mongo = require(__dirname+'/db.js') , db = Mongo.db.collection('accounts') , bcrypt = require('bcrypt') - , cache = require(__dirname+'/../lib/redis/redis.js'); + , cache = require(__dirname+'/../lib/redis/redis.js') + , { MONTH } = require(__dirname+'/../lib/converter/timeutils.js'); module.exports = { @@ -97,6 +98,14 @@ module.exports = { }); }, + getInactive: (duration=(MONTH*3)) => { + return db.find({ + 'lastActiveDate': { + '$lt': new Date(Date.now() - duration), + }, + }).toArray(); + }, + find: (filter, skip=0, limit=0) => { return db.find(filter, { 'projection': { @@ -175,6 +184,21 @@ module.exports = { return res; }, + clearStaffAndOwnedBoards: async (usernames) => { + const res = await db.updateMany({ + '_id': { + '$in': usernames + } + }, { + '$set': { + 'staffBoards': [], + 'ownedBoards': [], + } + }); + cache.del(usernames.map(n => `users:${n}`)); + return res; + }, + getOwnedOrStaffBoards: (usernames) => { return db.find({ '_id': { diff --git a/migrations/0.8.0.js b/migrations/0.8.0.js new file mode 100644 index 00000000..77c9851c --- /dev/null +++ b/migrations/0.8.0.js @@ -0,0 +1,16 @@ +'use strict'; + +const timeUtils = require(__dirname+'/../lib/converter/timeutils.js'); + +module.exports = async(db, redis) => { + console.log('add inactive account and board auto handling'); + await db.collection('globalsettings').updateOne({ _id: 'globalsettings' }, { + '$set': { + inactiveAccountTime: timeUtils.MONTH * 3, + inactiveAccountAction: 0, //no actions by default + abandonedBoardAction: 0, + }, + }); + console.log('Clearing globalsettings cache'); + await redis.deletePattern('globalsettings'); +}; diff --git a/models/forms/changeglobalsettings.js b/models/forms/changeglobalsettings.js index 37d5df72..3af6dfa3 100644 --- a/models/forms/changeglobalsettings.js +++ b/models/forms/changeglobalsettings.js @@ -108,6 +108,9 @@ module.exports = async (req, res) => { boardSettings: numberSetting(req.body.rate_limit_cost_board_settings, oldSettings.rateLimitCost.boardSettings), editPost: numberSetting(req.body.rate_limit_cost_edit_post, oldSettings.rateLimitCost.editPost), }, + inactiveAccountTime: numberSetting(req.body.inactive_account_time, oldSettings.inactiveAccountTime), + inactiveAccountAction: numberSetting(req.body.inactive_account_action, oldSettings.inactiveAccountAction), + abandonedBoardAction: numberSetting(req.body.abandoned_board_action, oldSettings.abandonedBoardAction), overboardLimit: numberSetting(req.body.overboard_limit, oldSettings.overboardLimit), overboardCatalogLimit: numberSetting(req.body.overboard_catalog_limit, oldSettings.overboardCatalogLimit), hotThreadsLimit: numberSetting(req.body.hot_threads_limit, oldSettings.hotThreadsLimit), diff --git a/package.json b/package.json index f1c3a967..1cc83631 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jschan", "version": "0.7.2", - "migrateVersion": "0.6.5", + "migrateVersion": "0.8.0", "description": "", "main": "server.js", "dependencies": { diff --git a/schedules/tasks/abandonedboards.js b/schedules/tasks/abandonedboards.js new file mode 100644 index 00000000..dccebc28 --- /dev/null +++ b/schedules/tasks/abandonedboards.js @@ -0,0 +1,26 @@ +'use strict'; + +const fetch = require('node-fetch') + , { debugLogs } = require(__dirname+'/../../configs/secrets.js') + , config = require(__dirname+'/../../lib/misc/config.js') + , Redis = require(__dirname+'/../../lib/redis/redis.js') + , { Boards, Accounts } = require(__dirname+'/../../db/') + , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js'); + +module.exports = { + + func: async () => { + + if (config.get.abandonedBoardAction === 0) { + return; + } + + //TODO: handle abandoned boards. 1=unlist, 2=unlist+lock, 3=delete + + }, + + interval: timeUtils.DAY, + immediate: false, + condition: 'abandonedBoardAction' + +}; diff --git a/schedules/tasks/inactiveaccounts.js b/schedules/tasks/inactiveaccounts.js new file mode 100644 index 00000000..ecc4ce3b --- /dev/null +++ b/schedules/tasks/inactiveaccounts.js @@ -0,0 +1,100 @@ +'use strict'; + +const fetch = require('node-fetch') + , { debugLogs } = require(__dirname+'/../../configs/secrets.js') + , config = require(__dirname+'/../../lib/misc/config.js') + , Redis = require(__dirname+'/../../lib/redis/redis.js') + , { Boards, Accounts } = require(__dirname+'/../../db/') + , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js'); + +module.exports = { + + func: async () => { + + if (config.get.inactiveAccountAction === 0) { + return; + } + + const inactiveAccounts = await Accounts.getInactive(config.get.inactiveAccountTime); + if (inactiveAccounts.length === 0) { + return; + } + + const cacheDeleteSet = new Set() + , boardBulkWrites = [] + , accountBulkWrites = [] + , inactiveWithBoards = inactiveAccounts.filter(acc => { + //only deal with boards if they have any (acc deletes still processed later) + return acc.ownedBoards.length > 0 || acc.staffBoards.length > 0; + }); + + let boardsPromise = null + , accountsPromise = null; + + //create promise for boards (remove staff.${username}) + inactiveWithBoards.forEach(acc => { + //remove account from staff and owner of all their boards + const accountBoards = [...acc.ownedBoards, ...acc.staffBoards]; + accountBoards.forEach(b => cacheDeleteSet.add(b)); + boardBulkWrites.push({ + updateOne: { + filter: { + '_id': { + '$in': accountBoards, + //better to do per board for staff unsets? or per-account... + } + }, + update: { + $unset: { + [`staff.${acc._id}`]: '', + }, + } + } + }); + acc.ownedBoards.forEach(ob => { + boardBulkWrites.push({ + updateOne: { + filter: { + '_id': ob, + }, + update: { + '$set': { + 'owner': null, + }, + } + } + }); + }); + }); + if (boardBulkWrites.length > 0) { + boardsPromise = Boards.db.bulkWrite(boardBulkWrites); + } + + //create promise for accounts (clearing staff positions or deleting fuly) + if (config.get.inactiveAccountAction === 2) { + debugLogs && console.log(`Deleting ${inactiveAccounts.length} inactive accounts`); + const inactiveUsernames = inactiveAccounts.map(acc => acc._id); + accountsPromise = Accounts.deleteMany(inactiveUsernames); + } else{ + debugLogs && console.log(`Removing staff positions from ${inactiveWithBoards.length} inactive accounts`); + const inactiveUsernames = inactiveWithBoards.map(acc => acc._id); + accountsPromise = Accounts.clearStaffAndOwnedBoards(inactiveUsernames); + } + + //execute promises + await Promise.all([ + accountsPromise, + boardsPromise, + ]); + + //clear caches + cacheDeleteSet.forEach(b => Redis.del(`board:${b}`)); + //users: cache already handled by Accounts.deleteMany or Accounts.clearStaffAndOwnedBoards + + }, + + interval: timeUtils.DAY, + immediate: true, + condition: 'inactiveAccountAction' + +}; diff --git a/views/pages/globalmanagesettings.pug b/views/pages/globalmanagesettings.pug index 0a1d312c..88a2009d 100644 --- a/views/pages/globalmanagesettings.pug +++ b/views/pages/globalmanagesettings.pug @@ -153,6 +153,22 @@ block content .row .label Max Homepage News Entries input(type='number', name='max_recent_news', value=settings.maxRecentNews) + .row + .label Inactive Account Time + input(type='text', name='inactive_account_time', placeholder='e.g. 1w', value=settings.inactiveAccountTime) + .row + .label Inactive Account Action + select(name='inactive_account_action') + option(value='0', selected=settings.inactiveAccountTime === 0) Do nothing + option(value='1', selected=settings.inactiveAccountTime === 1) Forfeit staff positions + option(value='2', selected=settings.inactiveAccountTime === 2) Delete Account + .row + .label Abandoned Board Action + select(name='abandoned_board_action') + option(value='0', selected=settings.abandonedBoardAction === 0) Do nothing + option(value='1', selected=settings.abandonedBoardAction === 1) Lock board + option(value='2', selected=settings.abandonedBoardAction === 2) Lock+unlist board + option(value='3', selected=settings.abandonedBoardAction === 3) Delete board .col.mr-5 From 4db2c9f6f5cff252b0a528dcd9216e0553140935 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 1 Jul 2022 22:19:59 +1000 Subject: [PATCH 2/5] Linting fixes, minus stuff we will need in abandoned board schedule --- schedules/tasks/abandonedboards.js | 5 ++--- schedules/tasks/inactiveaccounts.js | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/schedules/tasks/abandonedboards.js b/schedules/tasks/abandonedboards.js index dccebc28..c47f5d87 100644 --- a/schedules/tasks/abandonedboards.js +++ b/schedules/tasks/abandonedboards.js @@ -1,10 +1,9 @@ 'use strict'; -const fetch = require('node-fetch') - , { debugLogs } = require(__dirname+'/../../configs/secrets.js') +const { debugLogs } = require(__dirname+'/../../configs/secrets.js') , config = require(__dirname+'/../../lib/misc/config.js') , Redis = require(__dirname+'/../../lib/redis/redis.js') - , { Boards, Accounts } = require(__dirname+'/../../db/') + , { Boards } = require(__dirname+'/../../db/') , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js'); module.exports = { diff --git a/schedules/tasks/inactiveaccounts.js b/schedules/tasks/inactiveaccounts.js index ecc4ce3b..9315b37e 100644 --- a/schedules/tasks/inactiveaccounts.js +++ b/schedules/tasks/inactiveaccounts.js @@ -1,7 +1,6 @@ 'use strict'; -const fetch = require('node-fetch') - , { debugLogs } = require(__dirname+'/../../configs/secrets.js') +const { debugLogs } = require(__dirname+'/../../configs/secrets.js') , config = require(__dirname+'/../../lib/misc/config.js') , Redis = require(__dirname+'/../../lib/redis/redis.js') , { Boards, Accounts } = require(__dirname+'/../../db/') @@ -22,7 +21,6 @@ module.exports = { const cacheDeleteSet = new Set() , boardBulkWrites = [] - , accountBulkWrites = [] , inactiveWithBoards = inactiveAccounts.filter(acc => { //only deal with boards if they have any (acc deletes still processed later) return acc.ownedBoards.length > 0 || acc.staffBoards.length > 0; From 05413d72c64857f75d6786d97536ed5b081c1062 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 1 Jul 2022 23:42:22 +1000 Subject: [PATCH 3/5] Ref #418 add the abandoned boards handling Fix small bug with incorrect schema for the setting Set both schedules to immediate: false --- controllers/forms/globalsettings.js | 4 ++-- db/boards.js | 29 ++++++++++++++++++++++++++++- lib/misc/socketio.js | 3 +++ lib/redis/redis.js | 8 ++++---- schedules/tasks/abandonedboards.js | 24 ++++++++++++++++++++++-- schedules/tasks/inactiveaccounts.js | 2 +- 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/controllers/forms/globalsettings.js b/controllers/forms/globalsettings.js index b7dd2c5e..b6a9e089 100644 --- a/controllers/forms/globalsettings.js +++ b/controllers/forms/globalsettings.js @@ -69,8 +69,8 @@ module.exports = { return false; }, expected: true, error: 'Invalid reverse image search links URL format, must be a link containing %s where the url param belongs.' }, { result: numberBody(req.body.inactive_account_time), expected: true, error: 'Invalid inactive account time' }, - { result: numberBody(req.body.inactive_account_action, 0, 3), expected: true, error: 'Inactive account action must be a number from 0-3' }, - { result: numberBody(req.body.abandoned_board_action, 0, 2), expected: true, error: 'Abandoned board action must be a number from 0-2' }, + { result: numberBody(req.body.inactive_account_action, 0, 2), expected: true, error: 'Inactive account action must be a number from 0-2' }, + { result: numberBody(req.body.abandoned_board_action, 0, 3), expected: true, error: 'Abandoned board action must be a number from 0-3' }, { result: lengthBody(req.body.global_announcement, 0, 10000), expected: false, error: 'Global announcement must not exceed 10000 characters' }, { result: lengthBody(req.body.filters, 0, 50000), expected: false, error: 'Filter text cannot exceed 50000 characters' }, { result: numberBody(req.body.filter_mode, 0, 2), expected: true, error: 'Filter mode must be a number from 0-2' }, diff --git a/db/boards.js b/db/boards.js index 1d64dd13..d1a74872 100644 --- a/db/boards.js +++ b/db/boards.js @@ -4,7 +4,8 @@ const Mongo = require(__dirname+'/db.js') , cache = require(__dirname+'/../lib/redis/redis.js') , dynamicResponse = require(__dirname+'/../lib/misc/dynamic.js') , escapeRegExp = require(__dirname+'/../lib/input/escaperegexp.js') - , db = Mongo.db.collection('boards'); + , db = Mongo.db.collection('boards') + , config = require(__dirname+'/../lib/misc/config.js'); module.exports = { @@ -309,6 +310,32 @@ module.exports = { } }).toArray(); }, + + getAbandoned: () => { + return db.find({ + 'webring': false, + 'owner': null, + }).toArray(); + }, + + unlistMany: (boards) => { + const update = { + 'settings.unlistedLocal': true, + 'settings.unlistedWebring': true, + }; + if (config.get.abandonedBoardAction === 2) { + update['settings.lockMode'] = 2; + } + cache.srem('boards:listed', boards); + cache.del(boards.map(b => `board:${b}`)); + return db.updateMany({ + '_id': { + '$in': boards, + }, + }, { + '$set': update, + }); + }, count: (filter, showSensitive=false, webringSites=false) => { const addedFilter = {}; diff --git a/lib/misc/socketio.js b/lib/misc/socketio.js index 1560650c..0a75c1e0 100644 --- a/lib/misc/socketio.js +++ b/lib/misc/socketio.js @@ -80,6 +80,9 @@ module.exports = { }, emitRoom: (room, event, message) => { + if (!module.exports.io) { + return; //not initialized or in process that doesnt emit these events + } module.exports.io.to(room).emit(event, message); }, diff --git a/lib/redis/redis.js b/lib/redis/redis.js index bcb2819b..b7505572 100644 --- a/lib/redis/redis.js +++ b/lib/redis/redis.js @@ -77,9 +77,9 @@ module.exports = { return sharedClient.smembers(key); }, - //remove an item from a set - srem: (key, value) => { - return sharedClient.srem(key, value); + //remove item from a set + srem: (key, values) => { + return sharedClient.srem(key, values); }, //get random item from set @@ -89,7 +89,7 @@ module.exports = { //delete value with key del: (keyOrKeys) => { - if (Array.isArray(keyOrKeys)) { + if (Array.isArray(keyOrKeys)) { return sharedClient.del(...keyOrKeys); } else { return sharedClient.del(keyOrKeys); diff --git a/schedules/tasks/abandonedboards.js b/schedules/tasks/abandonedboards.js index c47f5d87..6187907e 100644 --- a/schedules/tasks/abandonedboards.js +++ b/schedules/tasks/abandonedboards.js @@ -4,7 +4,8 @@ const { debugLogs } = require(__dirname+'/../../configs/secrets.js') , config = require(__dirname+'/../../lib/misc/config.js') , Redis = require(__dirname+'/../../lib/redis/redis.js') , { Boards } = require(__dirname+'/../../db/') - , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js'); + , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js') + , deleteBoard = require(__dirname+'/../../models/forms/deleteboard.js'); module.exports = { @@ -14,7 +15,26 @@ module.exports = { return; } - //TODO: handle abandoned boards. 1=unlist, 2=unlist+lock, 3=delete + const abandonedBoards = await Boards.getAbandoned(); + if (abandonedBoards.length === 0) { + return; + } + + if (config.get.abandonedBoardAction <= 2) { + debugLogs && console.log(`Unlisting${config.get.abandonedBoardAction === 2 ? '+Locking' : ''} ${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); + } + } + } }, diff --git a/schedules/tasks/inactiveaccounts.js b/schedules/tasks/inactiveaccounts.js index 9315b37e..193a675d 100644 --- a/schedules/tasks/inactiveaccounts.js +++ b/schedules/tasks/inactiveaccounts.js @@ -92,7 +92,7 @@ module.exports = { }, interval: timeUtils.DAY, - immediate: true, + immediate: false, condition: 'inactiveAccountAction' }; From 425c15f1ceef25a28d25c87f6aa3c505b69d35cc Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Fri, 1 Jul 2022 23:45:52 +1000 Subject: [PATCH 4/5] linting --- schedules/tasks/abandonedboards.js | 1 - 1 file changed, 1 deletion(-) diff --git a/schedules/tasks/abandonedboards.js b/schedules/tasks/abandonedboards.js index 6187907e..92e3cbbb 100644 --- a/schedules/tasks/abandonedboards.js +++ b/schedules/tasks/abandonedboards.js @@ -2,7 +2,6 @@ const { debugLogs } = require(__dirname+'/../../configs/secrets.js') , config = require(__dirname+'/../../lib/misc/config.js') - , Redis = require(__dirname+'/../../lib/redis/redis.js') , { Boards } = require(__dirname+'/../../db/') , timeUtils = require(__dirname+'/../../lib/converter/timeutils.js') , deleteBoard = require(__dirname+'/../../models/forms/deleteboard.js'); From a58d486a92dfb7d411c436387f52414eba3b2d23 Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Sat, 2 Jul 2022 02:31:02 +1000 Subject: [PATCH 5/5] Dont repeat actions for boards that are already locked(or +unlisted) and not being deleted --- db/boards.js | 27 +++++++++++++++++++++------ schedules/tasks/abandonedboards.js | 4 ++-- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/db/boards.js b/db/boards.js index d1a74872..215be96a 100644 --- a/db/boards.js +++ b/db/boards.js @@ -311,20 +311,35 @@ module.exports = { }).toArray(); }, - getAbandoned: () => { - return db.find({ + getAbandoned: (action=0) => { + const filter = { 'webring': false, 'owner': null, - }).toArray(); + }; + if (action === 1) { + //if just locking, only match unlocked boards + filter['settings.lockMode'] = { '$lt': 2 }; + } else if (action === 2) { + //if locking+unlisting, match ones that satisfy any of the conditions + filter['$or'] = [ + { 'settings.unlistedWebring': false }, + { 'settings.unlistedLocal': false }, + { 'settings.lockMode': { '$lt': 2 } }, + ]; + } + //else we return boards purely based on owner: null because they are going to be deleted anyway + return db + .find(filter) + .toArray(); }, unlistMany: (boards) => { const update = { - 'settings.unlistedLocal': true, - 'settings.unlistedWebring': true, + 'settings.lockMode': 2, }; if (config.get.abandonedBoardAction === 2) { - update['settings.lockMode'] = 2; + update['settings.unlistedLocal'] = true; + update['settings.unlistedWebring'] = true; } cache.srem('boards:listed', boards); cache.del(boards.map(b => `board:${b}`)); diff --git a/schedules/tasks/abandonedboards.js b/schedules/tasks/abandonedboards.js index 92e3cbbb..7bfa90f2 100644 --- a/schedules/tasks/abandonedboards.js +++ b/schedules/tasks/abandonedboards.js @@ -14,13 +14,13 @@ module.exports = { return; } - const abandonedBoards = await Boards.getAbandoned(); + const abandonedBoards = await Boards.getAbandoned(config.get.abandonedBoardAction); if (abandonedBoards.length === 0) { return; } if (config.get.abandonedBoardAction <= 2) { - debugLogs && console.log(`Unlisting${config.get.abandonedBoardAction === 2 ? '+Locking' : ''} ${abandonedBoards.length} abandoned boards.`); + 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