diff --git a/public/language/en-GB/notifications.json b/public/language/en-GB/notifications.json
index 0ec141d742..33014b5c80 100644
--- a/public/language/en-GB/notifications.json
+++ b/public/language/en-GB/notifications.json
@@ -51,6 +51,8 @@
"posts-exported": "%1 posts exported, click to download",
"uploads-exported": "%1 uploads exported, click to download",
"users-csv-exported": "Users csv exported, click to download",
+ "post-queue-accepted": "Your queued post has been accepted. Click here to see your post.",
+ "post-queue-rejected": "Your queued post has been rejected.",
"email-confirmed": "Email Confirmed",
"email-confirmed-message": "Thank you for validating your email. Your account is now fully activated.",
diff --git a/public/language/en-GB/success.json b/public/language/en-GB/success.json
index 17093d3efe..6923dd3b8a 100644
--- a/public/language/en-GB/success.json
+++ b/public/language/en-GB/success.json
@@ -1,7 +1,7 @@
{
"success": "Success",
"topic-post": "You have successfully posted.",
- "post-queued": "Your post is queued for approval.",
+ "post-queued": "Your post is queued for approval. You will get a notification when it is accepted or rejected.",
"authentication-successful": "Authentication Successful",
"settings-saved": "Settings saved!"
}
\ No newline at end of file
diff --git a/src/posts/queue.js b/src/posts/queue.js
index f3bb96b56b..d523420e43 100644
--- a/src/posts/queue.js
+++ b/src/posts/queue.js
@@ -228,10 +228,15 @@ module.exports = function (Posts) {
}
Posts.removeFromQueue = async function (id) {
+ const data = await getParsedObject(id);
+ if (!data) {
+ return;
+ }
await removeQueueNotification(id);
await db.sortedSetRemove('post:queue', id);
await db.delete(`post:queue:${id}`);
cache.del('post-queue');
+ return data;
};
Posts.submitFromQueue = async function (id) {
@@ -240,11 +245,14 @@ module.exports = function (Posts) {
return;
}
if (data.type === 'topic') {
- await createTopic(data.data);
+ const result = await createTopic(data.data);
+ data.pid = result.postData.pid;
} else if (data.type === 'reply') {
- await createReply(data.data);
+ const result = await createReply(data.data);
+ data.pid = result.pid;
}
await Posts.removeFromQueue(id);
+ return data;
};
async function getParsedObject(id) {
@@ -260,6 +268,7 @@ module.exports = function (Posts) {
async function createTopic(data) {
const result = await topics.post(data);
socketHelpers.notifyNew(data.uid, 'newTopic', { posts: [result.postData], topic: result.topicData });
+ return result;
}
async function createReply(data) {
@@ -270,6 +279,7 @@ module.exports = function (Posts) {
'downvote:disabled': !!meta.config['downvote:disabled'],
};
socketHelpers.notifyNew(data.uid, 'newPost', result);
+ return postData;
}
Posts.editQueuedContent = async function (uid, editData) {
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 2af48a17c6..aee411a0d1 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -7,6 +7,7 @@ const plugins = require('../plugins');
const meta = require('../meta');
const topics = require('../topics');
const user = require('../user');
+const notifications = require('../notifications');
const socketHelpers = require('./helpers');
const utils = require('../utils');
const api = require('../api');
@@ -130,11 +131,13 @@ SocketPosts.getReplies = async function (socket, pid) {
};
SocketPosts.accept = async function (socket, data) {
- await acceptOrReject(posts.submitFromQueue, socket, data);
+ const result = await acceptOrReject(posts.submitFromQueue, socket, data);
+ await sendQueueNotification('post-queue-accepted', result.uid, `/post/${result.pid}`);
};
SocketPosts.reject = async function (socket, data) {
- await acceptOrReject(posts.removeFromQueue, socket, data);
+ const result = await acceptOrReject(posts.removeFromQueue, socket, data);
+ await sendQueueNotification('post-queue-rejected', result.uid, '/');
};
async function acceptOrReject(method, socket, data) {
@@ -142,7 +145,18 @@ async function acceptOrReject(method, socket, data) {
if (!canEditQueue) {
throw new Error('[[error:no-privileges]]');
}
- await method(data.id);
+ return await method(data.id);
+}
+
+async function sendQueueNotification(type, targetUid, path) {
+ const notifObj = await notifications.create({
+ type: type,
+ nid: `${type}-${targetUid}-${path}`,
+ bodyShort: type === 'post-queue-accepted' ?
+ '[[notifications:post-queue-accepted]]' : '[[notifications:post-queue-rejected]]',
+ path: path,
+ });
+ await notifications.push(notifObj, [targetUid]);
}
SocketPosts.editQueuedContent = async function (socket, data) {