|
|
|
@ -95,6 +95,7 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
|
if (req.body.delete || req.body.delete_ip_board || req.body.delete_ip_global) { |
|
|
|
|
if (req.body.delete_ip_board || req.body.delete_ip_global) { |
|
|
|
|
const deletePostIps = res.locals.posts.map(x => x.ip); |
|
|
|
|
let query = { |
|
|
|
@ -107,46 +108,29 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} |
|
|
|
|
const deleteIpPosts = await Posts.db.find(query).toArray(); |
|
|
|
|
res.locals.posts = res.locals.posts.concat(deleteIpPosts); |
|
|
|
|
if (deleteIpPosts && deleteIpPosts.length > 0) { |
|
|
|
|
const { action, message } = await deletePosts(deleteIpPosts, req.params.board); |
|
|
|
|
messages.push(message); |
|
|
|
|
if (action) { |
|
|
|
|
aggregateNeeded = true; |
|
|
|
|
} else { |
|
|
|
|
req.body.delete_ip_board = false; |
|
|
|
|
req.body.delete_ip_global = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
if (req.body.delete_file) { |
|
|
|
|
const { message } = await deletePostsFiles(res.locals.posts, false); //delete files, not just unlink
|
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
|
} else if (req.body.delete) { |
|
|
|
|
const { action, message } = await deletePosts(passwordPosts, req.params.board); |
|
|
|
|
const { action, message } = await deletePosts(res.locals.posts, req.body.delete_ip_global ? null : req.params.board); |
|
|
|
|
messages.push(message); |
|
|
|
|
if (action) { |
|
|
|
|
aggregateNeeded = true; |
|
|
|
|
} else { |
|
|
|
|
req.body.delete = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// if it was getting deleted, we cant do any of these
|
|
|
|
|
if (req.body.delete_file || req.body.unlink_file) { |
|
|
|
|
if (req.body.unlink_file || req.body.delete_file) { |
|
|
|
|
const { message, action, query } = await deletePostsFiles(passwordPosts, req.body.unlink_file); |
|
|
|
|
if (action) { |
|
|
|
|
aggregateNeeded = true; |
|
|
|
|
passwordCombinedQuery[action] = { ...passwordCombinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.delete_file = false; |
|
|
|
|
req.body.unlink_file = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} else if (req.body.spoiler) { |
|
|
|
|
const { message, action, query } = spoilerPosts(passwordPosts); |
|
|
|
|
if (action) { |
|
|
|
|
passwordCombinedQuery[action] = { ...passwordCombinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.spoiler = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -155,9 +139,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = sagePosts(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.sage = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -165,9 +146,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = lockPosts(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.lock = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -175,9 +153,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = stickyPosts(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.sticky = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -185,9 +160,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = cyclePosts(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.cyclic = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -202,9 +174,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = dismissReports(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.dismiss = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
@ -219,14 +188,10 @@ module.exports = async (req, res, next) => { |
|
|
|
|
const { message, action, query } = dismissGlobalReports(res.locals.posts); |
|
|
|
|
if (action) { |
|
|
|
|
combinedQuery[action] = { ...combinedQuery[action], ...query} |
|
|
|
|
} else { |
|
|
|
|
req.body.global_dismiss = false; |
|
|
|
|
res.locals.actions.anyValid--; |
|
|
|
|
} |
|
|
|
|
messages.push(message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (res.locals.actions.anyValid > 0) { |
|
|
|
|
const bulkWrites = []; |
|
|
|
|
if (Object.keys(combinedQuery).length > 0) { |
|
|
|
|
bulkWrites.push({ |
|
|
|
@ -379,7 +344,6 @@ module.exports = async (req, res, next) => { |
|
|
|
|
} |
|
|
|
|
await Promise.all(parallelPromises); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
|
return next(err); |
|
|
|
|