From 0ce3e4b6917805d3f43b534661f66010995de34e Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Wed, 16 Aug 2017 15:15:54 -0400 Subject: [PATCH] post-queue show category, send notification --- .../en-GB/admin/manage/post-queue.json | 4 ++- public/language/en-GB/notifications.json | 1 + src/controllers/admin/postqueue.js | 27 ++++++++++++++++++- src/posts/queue.js | 20 ++++++++++++++ src/views/admin/manage/post-queue.tpl | 9 ++++++- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/public/language/en-GB/admin/manage/post-queue.json b/public/language/en-GB/admin/manage/post-queue.json index 5c52e25538..f748fb0ee2 100644 --- a/public/language/en-GB/admin/manage/post-queue.json +++ b/public/language/en-GB/admin/manage/post-queue.json @@ -2,7 +2,9 @@ "post-queue": "Post Queue", "description": "There are no posts in the post queue.
To enable this feature, go to Settings → Post → Posting Restrictions and enable Post Queue.", "user": "User", + "category": "Category", "title": "Title", "content": "Content", - "posted": "Posted" + "posted": "Posted", + "reply-to": "Reply to \"%1\"" } \ No newline at end of file diff --git a/public/language/en-GB/notifications.json b/public/language/en-GB/notifications.json index 8c7ed9d07a..7812eabf7c 100644 --- a/public/language/en-GB/notifications.json +++ b/public/language/en-GB/notifications.json @@ -45,6 +45,7 @@ "new_register": "%1 sent a registration request.", "new_register_multiple": "There are %1 registration requests awaiting review.", "flag_assigned_to_you": "Flag %1 has been assigned to you", + "post_awaiting_review": "Post awaiting review", "email-confirmed": "Email Confirmed", "email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.", diff --git a/src/controllers/admin/postqueue.js b/src/controllers/admin/postqueue.js index e401f7dedd..749b4c0a2a 100644 --- a/src/controllers/admin/postqueue.js +++ b/src/controllers/admin/postqueue.js @@ -4,6 +4,8 @@ var async = require('async'); var db = require('../../database'); var user = require('../../user'); +var topics = require('../../topics'); +var categories = require('../../categories'); var pagination = require('../../pagination'); var utils = require('../../utils'); @@ -51,11 +53,34 @@ postQueueController.get = function (req, res, next) { }); user.getUsersFields(uids, ['username', 'userslug', 'picture'], next); }, - function (userData) { + function (userData, next) { postData.forEach(function (postData, index) { postData.user = userData[index]; }); + async.map(postData, function (postData, next) { + async.waterfall([ + function (next) { + if (postData.data.cid) { + next(null, { cid: postData.data.cid }); + } else if (postData.data.tid) { + topics.getTopicFields(postData.data.tid, ['title', 'cid'], next); + } else { + next(null, { cid: 0 }); + } + }, + function (topicData, next) { + postData.topic = topicData; + categories.getCategoryData(topicData.cid, next); + }, + function (categoryData, next) { + postData.category = categoryData; + next(null, postData); + }, + ], next); + }, next); + }, + function (postData) { res.render('admin/manage/post-queue', { title: '[[pages:post-queue]]', posts: postData, diff --git a/src/posts/queue.js b/src/posts/queue.js index 3b9f555f9d..7e0e90720f 100644 --- a/src/posts/queue.js +++ b/src/posts/queue.js @@ -6,6 +6,7 @@ var db = require('../database'); var user = require('../user'); var meta = require('../meta'); var topics = require('../topics'); +var notifications = require('../notifications'); var privileges = require('../privileges'); var socketHelpers = require('../socket.io/helpers'); @@ -43,6 +44,22 @@ module.exports = function (Posts) { function (next) { user.setUserField(data.uid, 'lastposttime', Date.now(), next); }, + function (next) { + notifications.create({ + nid: 'post-queued-' + id, + mergeId: 'post-queue', + bodyShort: '[[notifications:post_awaiting_review]]', + bodyLong: data.content, + path: '/post-queue', + }, next); + }, + function (notification, next) { + if (notification) { + notifications.pushGroups(notification, ['administrators', 'Global Moderators'], next); + } else { + next(); + } + }, function (next) { next(null, { queued: true, @@ -92,6 +109,9 @@ module.exports = function (Posts) { function (next) { db.delete('post:queue:' + id, next); }, + function (next) { + notifications.rescind('post-queued-' + id, next); + }, ], callback); }; diff --git a/src/views/admin/manage/post-queue.tpl b/src/views/admin/manage/post-queue.tpl index 86c70f2f21..001479aa58 100644 --- a/src/views/admin/manage/post-queue.tpl +++ b/src/views/admin/manage/post-queue.tpl @@ -16,6 +16,7 @@ [[admin/manage/post-queue:user]] + [[admin/manage/post-queue:category]] [[admin/manage/post-queue:title]] [[admin/manage/post-queue:content]] [[admin/manage/post-queue:posted]] @@ -33,9 +34,15 @@ + {posts.category.name} + + + + [[admin/manage/post-queue:reply-to, {posts.topic.title}]] + {posts.data.title} - + {posts.data.content}