mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
feat: post-queue hooks, closes #10381
This commit is contained in:
@@ -239,18 +239,26 @@ module.exports = function (Posts) {
|
|||||||
if (!data) {
|
if (!data) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const result = await plugins.hooks.fire('filter:post-queue:removeFromQueue', { data: data });
|
||||||
|
await removeFromQueue(id);
|
||||||
|
plugins.hooks.fire('action:post-queue:removeFromQueue', { data: result.data });
|
||||||
|
return result.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
async function removeFromQueue(id) {
|
||||||
await removeQueueNotification(id);
|
await removeQueueNotification(id);
|
||||||
await db.sortedSetRemove('post:queue', id);
|
await db.sortedSetRemove('post:queue', id);
|
||||||
await db.delete(`post:queue:${id}`);
|
await db.delete(`post:queue:${id}`);
|
||||||
cache.del('post-queue');
|
cache.del('post-queue');
|
||||||
return data;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Posts.submitFromQueue = async function (id) {
|
Posts.submitFromQueue = async function (id) {
|
||||||
const data = await getParsedObject(id);
|
let data = await getParsedObject(id);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const result = await plugins.hooks.fire('filter:post-queue:submitFromQueue', { data: data });
|
||||||
|
data = result.data;
|
||||||
if (data.type === 'topic') {
|
if (data.type === 'topic') {
|
||||||
const result = await createTopic(data.data);
|
const result = await createTopic(data.data);
|
||||||
data.pid = result.postData.pid;
|
data.pid = result.postData.pid;
|
||||||
@@ -258,7 +266,8 @@ module.exports = function (Posts) {
|
|||||||
const result = await createReply(data.data);
|
const result = await createReply(data.data);
|
||||||
data.pid = result.pid;
|
data.pid = result.pid;
|
||||||
}
|
}
|
||||||
await Posts.removeFromQueue(id);
|
await removeFromQueue(id);
|
||||||
|
plugins.hooks.fire('action:post-queue:submitFromQueue', { data: data });
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user