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.
35 lines
663 B
35 lines
663 B
'use strict';
|
|
|
|
const { ObjectId } = require(__dirname+'/../../db/db.js');
|
|
|
|
module.exports = (req, res) => {
|
|
|
|
const report = {
|
|
'id': ObjectId(),
|
|
'reason': req.body.report_reason,
|
|
'date': new Date(),
|
|
'ip': {
|
|
'single': res.locals.ip.single,
|
|
'raw': res.locals.ip.raw
|
|
}
|
|
}
|
|
|
|
const ret = {
|
|
message: `Reported ${res.locals.posts.length} post${res.locals.posts.length > 1 ? 's' : ''}`,
|
|
action: '$push',
|
|
query: {}
|
|
};
|
|
const query = {
|
|
'$each': [report],
|
|
'$slice': -5 //limit number of reports
|
|
}
|
|
if (req.body.global_report) {
|
|
ret.query['globalreports'] = query;
|
|
}
|
|
if (req.body.report) {
|
|
ret.query['reports'] = query;
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|