feat: #9511 send notifications on accept/reject

This commit is contained in:
Barış Soner Uşaklı
2021-04-26 14:50:44 -04:00
parent 2bfa63aecf
commit b40fc4b64d
4 changed files with 32 additions and 6 deletions

View File

@@ -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) {