mirror of https://gitgud.io/fatchan/jschan.git
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.
25 lines
495 B
25 lines
495 B
'use strict';
|
|
|
|
module.exports = (req, res) => {
|
|
|
|
const filteredposts = res.locals.posts.filter(post => {
|
|
return (req.body.global_dismiss && post.globalreports.length > 0)
|
|
|| (req.body.dismiss && post.reports.length > 0);
|
|
});
|
|
|
|
if (filteredposts.length === 0) {
|
|
return {
|
|
message: 'No report(s) to dismiss'
|
|
};
|
|
}
|
|
|
|
const ret = {
|
|
message: 'Dismissed reports',
|
|
action: '$set',
|
|
query: {}
|
|
};
|
|
ret.query[`${req.body.global_dismiss ? 'global' : ''}reports`] = [];
|
|
|
|
return ret;
|
|
|
|
};
|
|
|