diff --git a/src/models/report.js b/src/models/report.js index 9544306..a801418 100644 --- a/src/models/report.js +++ b/src/models/report.js @@ -14,14 +14,16 @@ const ReportSchema = new Schema({ type: Boolean, default: false }, + note: String, resolved_by: Number, resolved_at: Date, }); -ReportSchema.methods.resolve = async function(pid) { +ReportSchema.methods.resolve = async function(pid, note) { this.set('resolved', true); this.set('resolved_by', pid); this.set('resolved_at', new Date()); + this.set('note', note); await this.save(); }; diff --git a/src/services/juxt-web/routes/admin/admin.js b/src/services/juxt-web/routes/admin/admin.js index a1ea5c3..9c11c0e 100644 --- a/src/services/juxt-web/routes/admin/admin.js +++ b/src/services/juxt-web/routes/admin/admin.js @@ -42,6 +42,10 @@ router.get('/', async function (req, res) { }); router.delete('/:reportID', async function (req, res) { + if (!req.moderator) { + return res.sendStatus(401); + } + const report = await database.getReportById(req.params.reportID); if (!report) { return res.sendStatus(402); @@ -51,12 +55,23 @@ router.delete('/:reportID', async function (req, res) { return res.sendStatus(404); } + await post.removePost(req.query.reason ? req.query.reason : 'Removed by moderator', req.pid); + await report.resolve(req.pid, req.query.reason ? req.query.reason : 'Removed by moderator'); + + return res.sendStatus(200); +}); + +router.put('/:reportID', async function (req, res) { if (!req.moderator) { return res.sendStatus(401); } - await post.removePost(req.query.reason ? req.query.reason : 'Removed by moderator', req.pid); - await report.resolve(req.pid); + const report = await database.getReportById(req.params.reportID); + if (!report) { + return res.sendStatus(402); + } + + await report.resolve(req.pid, req.query.reason); return res.sendStatus(200); }); diff --git a/src/webfiles/ctr/partials/new_post.ejs b/src/webfiles/ctr/partials/new_post.ejs index 5085305..0a64d8b 100644 --- a/src/webfiles/ctr/partials/new_post.ejs +++ b/src/webfiles/ctr/partials/new_post.ejs @@ -42,7 +42,7 @@
+ <% var yeahCount = post.yeahs.length > 10 ? 10 : post.yeahs.length %>
+ <%for(var i = 0; i < yeahCount; i++) {%>
+
+
<%}%>