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.
26 lines
454 B
26 lines
454 B
6 years ago
|
'use strict';
|
||
|
|
||
5 years ago
|
const Posts = require(__dirname+'/../../db/posts.js');
|
||
6 years ago
|
|
||
5 years ago
|
module.exports = (req, posts) => {
|
||
6 years ago
|
|
||
6 years ago
|
const ip = req.headers['x-real-ip'] || req.connection.remoteAddress;
|
||
|
const report = {
|
||
5 years ago
|
'reason': req.body.report_reason,
|
||
6 years ago
|
'date': new Date(),
|
||
|
'ip': ip
|
||
|
}
|
||
|
|
||
5 years ago
|
return {
|
||
|
message: `Reported ${posts.length} post(s)`,
|
||
|
action: '$push',
|
||
|
query: {
|
||
5 years ago
|
'reports': {
|
||
|
'$each': [report],
|
||
|
'$slice': -5 //limit number of reports
|
||
|
}
|
||
5 years ago
|
}
|
||
|
};
|
||
6 years ago
|
|
||
|
}
|