mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add merge/fork hooks
This commit is contained in:
@@ -41,12 +41,18 @@ module.exports = function (Topics) {
|
||||
}
|
||||
|
||||
const scheduled = postData.timestamp > Date.now();
|
||||
const tid = await Topics.create({
|
||||
const params = {
|
||||
uid: postData.uid,
|
||||
title: title,
|
||||
cid: cid,
|
||||
timestamp: scheduled && postData.timestamp,
|
||||
};
|
||||
const result = await plugins.hooks.fire('filter:topic.fork', {
|
||||
params: params,
|
||||
tid: postData.tid,
|
||||
});
|
||||
|
||||
const tid = await Topics.create(result.params);
|
||||
await Topics.updateTopicBookmarks(fromTid, pids);
|
||||
|
||||
await async.eachSeries(pids, async (pid) => {
|
||||
|
||||
@@ -51,11 +51,16 @@ module.exports = function (Topics) {
|
||||
|
||||
async function createNewTopic(title, oldestTid) {
|
||||
const topicData = await Topics.getTopicFields(oldestTid, ['uid', 'cid']);
|
||||
const tid = await Topics.create({
|
||||
const params = {
|
||||
uid: topicData.uid,
|
||||
cid: topicData.cid,
|
||||
title: title,
|
||||
};
|
||||
const result = await plugins.hooks.fire('filter:topic.mergeCreateNewTopic', {
|
||||
oldestTid: oldestTid,
|
||||
params: params,
|
||||
});
|
||||
const tid = await Topics.create(result.params);
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user