|
|
|
@ -15,6 +15,7 @@ const { Posts, Boards, Modlogs } = require(__dirname+'/../../db/') |
|
|
|
|
, movePosts = require(__dirname+'/moveposts.js') |
|
|
|
|
, { remove } = require('fs-extra') |
|
|
|
|
, uploadDirectory = require(__dirname+'/../../lib/file/uploaddirectory.js') |
|
|
|
|
, ModlogActions = require(__dirname+'/../../lib/input/modlogactions.js') |
|
|
|
|
, getAffectedBoards = require(__dirname+'/../../lib/misc/affectedboards.js') |
|
|
|
|
, dynamicResponse = require(__dirname+'/../../lib/misc/dynamic.js') |
|
|
|
|
, { Permissions } = require(__dirname+'/../../lib/permission/permissions.js') |
|
|
|
@ -25,6 +26,8 @@ const { Posts, Boards, Modlogs } = require(__dirname+'/../../db/') |
|
|
|
|
|
|
|
|
|
module.exports = async (req, res, next) => { |
|
|
|
|
|
|
|
|
|
const { __ } = res.locals; |
|
|
|
|
|
|
|
|
|
//try to set a good redirect
|
|
|
|
|
let redirect = req.headers.referer; |
|
|
|
|
if (!redirect) { |
|
|
|
@ -54,8 +57,8 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} |
|
|
|
|
if (passwordPosts.length === 0) { |
|
|
|
|
return dynamicResponse(req, res, 403, 'message', { |
|
|
|
|
'title': 'Forbidden', |
|
|
|
|
'error': 'Password did not match any selected posts', |
|
|
|
|
'title': __('Forbidden'), |
|
|
|
|
'error': __('Password did not match any selected posts'), |
|
|
|
|
redirect, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -89,14 +92,14 @@ module.exports = async (req, res, next) => { |
|
|
|
|
if (req.body.ban || req.body.global_ban || req.body.report_ban || req.body.global_report_ban) { |
|
|
|
|
const { message, action, query } = await banPoster(req, res, next); |
|
|
|
|
if (req.body.ban) { |
|
|
|
|
modlogActions.push('Ban'); |
|
|
|
|
modlogActions.push(ModlogActions.BAN); |
|
|
|
|
} else if (req.body.global_ban) { |
|
|
|
|
modlogActions.push('Global Ban'); |
|
|
|
|
modlogActions.push(ModlogActions.GLOBAL_BAN); |
|
|
|
|
} |
|
|
|
|
if (req.body.report_ban) { |
|
|
|
|
modlogActions.push('Ban reporter'); |
|
|
|
|
modlogActions.push(ModlogActions.BAN_REPORTER); |
|
|
|
|
} else if (req.body.global_report_ban) { |
|
|
|
|
modlogActions.push('Global ban reporter'); |
|
|
|
|
modlogActions.push(ModlogActions.GLOBAL_BAN_REPORTER); |
|
|
|
|
} |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
@ -117,8 +120,8 @@ module.exports = async (req, res, next) => { |
|
|
|
|
}); |
|
|
|
|
if (protectedThread === true) { |
|
|
|
|
return dynamicResponse(req, res, 403, 'message', { |
|
|
|
|
'title': 'Forbidden', |
|
|
|
|
'error': 'You cannot delete old threads or threads with too many replies', |
|
|
|
|
'title': __('Forbidden'), |
|
|
|
|
'error': __('You cannot delete old threads or threads with too many replies'), |
|
|
|
|
redirect, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -173,11 +176,11 @@ module.exports = async (req, res, next) => { |
|
|
|
|
messages.push(message); |
|
|
|
|
if (action) { |
|
|
|
|
if (req.body.delete) { |
|
|
|
|
modlogActions.push('Delete'); |
|
|
|
|
modlogActions.push(ModlogActions.DELETE); |
|
|
|
|
} else if (req.body.delete_ip_board) { |
|
|
|
|
modlogActions.push('Delete by IP'); |
|
|
|
|
modlogActions.push(ModlogActions.DELETE_BY_IP); |
|
|
|
|
} else if (req.body.delete_ip_global) { |
|
|
|
|
modlogActions.push('Global delete by IP'); |
|
|
|
|
modlogActions.push(ModlogActions.GLOBAL_DELETE_BY_IP); |
|
|
|
|
} |
|
|
|
|
recalculateThreadMetadata = true; |
|
|
|
|
} |
|
|
|
@ -196,7 +199,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} |
|
|
|
|
const { message, action } = await movePosts(req, res); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Moved'); |
|
|
|
|
modlogActions.push(ModlogActions.MOVE); |
|
|
|
|
recalculateThreadMetadata = true; |
|
|
|
|
if (res.locals.destinationBoard && res.locals.destinationThread) { |
|
|
|
|
res.locals.posts.push(res.locals.destinationThread); |
|
|
|
@ -213,9 +216,9 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = await deletePostsFiles(res.locals, req.body.unlink_file); |
|
|
|
|
if (action) { |
|
|
|
|
if (req.body.unlink_file) { |
|
|
|
|
modlogActions.push('Unlink files'); |
|
|
|
|
modlogActions.push(ModlogActions.UNLINK_FILES); |
|
|
|
|
} else if (req.body.delete_file) { |
|
|
|
|
modlogActions.push('Delete files'); |
|
|
|
|
modlogActions.push(ModlogActions.DELETE_FILES); |
|
|
|
|
} |
|
|
|
|
recalculateThreadMetadata = true; |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
@ -224,7 +227,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} else if (req.body.spoiler) { |
|
|
|
|
const { message, action, query } = spoilerPosts(res.locals); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Spoiler files'); |
|
|
|
|
modlogActions.push(ModlogActions.SPOILER_FILES); |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
@ -233,7 +236,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
if (req.body.bumplock) { |
|
|
|
|
const { message, action, query } = bumplockPosts(res.locals); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Bumplock'); |
|
|
|
|
modlogActions.push(ModlogActions.BUMPLOCK); |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
@ -241,7 +244,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
if (req.body.lock) { |
|
|
|
|
const { message, action, query } = lockPosts(res.locals); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Lock'); |
|
|
|
|
modlogActions.push(ModlogActions.LOCK); |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
@ -249,7 +252,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
if (req.body.sticky != null) { |
|
|
|
|
const { message, action, query } = stickyPosts(res.locals, req.body.sticky); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Sticky'); |
|
|
|
|
modlogActions.push(ModlogActions.STICKY); |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
@ -257,7 +260,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
if (req.body.cyclic) { |
|
|
|
|
const { message, action, query } = cyclePosts(res.locals); |
|
|
|
|
if (action) { |
|
|
|
|
modlogActions.push('Cycle'); |
|
|
|
|
modlogActions.push(ModlogActions.CYCLE); |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
@ -274,9 +277,9 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = dismissReports(req, res); |
|
|
|
|
if (action) { |
|
|
|
|
if (req.body.dismiss) { |
|
|
|
|
modlogActions.push('Dismiss reports'); |
|
|
|
|
modlogActions.push(ModlogActions.DISMISS); |
|
|
|
|
} else if (req.body.global_dismiss) { |
|
|
|
|
modlogActions.push('Dismiss global reports'); |
|
|
|
|
modlogActions.push(ModlogActions.GLOBAL_DISMISS); |
|
|
|
|
} |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query}; |
|
|
|
|
} |
|
|
|
|