mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
feat: closes #10018
This commit is contained in:
@@ -60,7 +60,7 @@ Events._types = {
|
|||||||
},
|
},
|
||||||
fork: {
|
fork: {
|
||||||
icon: 'fa-code-fork',
|
icon: 'fa-code-fork',
|
||||||
text: '[[topic:forked-by]]'
|
text: '[[topic:forked-by]]',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -159,7 +159,7 @@ async function modifyEvent({ tid, uid, eventIds, timestamps, events }) {
|
|||||||
Events.log = async (tid, payload) => {
|
Events.log = async (tid, payload) => {
|
||||||
const topics = require('.');
|
const topics = require('.');
|
||||||
const { type } = payload;
|
const { type } = payload;
|
||||||
const now = Date.now();
|
const timestamp = payload.timestamp || Date.now();
|
||||||
|
|
||||||
if (!Events._types.hasOwnProperty(type)) {
|
if (!Events._types.hasOwnProperty(type)) {
|
||||||
throw new Error(`[[error:topic-event-unrecognized, ${type}]]`);
|
throw new Error(`[[error:topic-event-unrecognized, ${type}]]`);
|
||||||
@@ -171,12 +171,12 @@ Events.log = async (tid, payload) => {
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
db.setObject(`topicEvent:${eventId}`, payload),
|
db.setObject(`topicEvent:${eventId}`, payload),
|
||||||
db.sortedSetAdd(`topic:${tid}:events`, now, eventId),
|
db.sortedSetAdd(`topic:${tid}:events`, timestamp, eventId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let events = await modifyEvent({
|
let events = await modifyEvent({
|
||||||
eventIds: [eventId],
|
eventIds: [eventId],
|
||||||
timestamps: [now],
|
timestamps: [timestamp],
|
||||||
events: [payload],
|
events: [payload],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ module.exports = function (Topics) {
|
|||||||
downvotes: postData.downvotes,
|
downvotes: postData.downvotes,
|
||||||
}),
|
}),
|
||||||
db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], postData.votes, tid),
|
db.sortedSetsAdd(['topics:votes', `cid:${cid}:tids:votes`], postData.votes, tid),
|
||||||
Topics.events.log(fromTid, { type: 'fork', uid, href: `/topic/${tid}` })
|
Topics.events.log(fromTid, { type: 'fork', uid, href: `/topic/${tid}`, timestamp: postData.timestamp }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
plugins.hooks.fire('action:topic.fork', { tid: tid, fromTid: fromTid, uid: uid });
|
plugins.hooks.fire('action:topic.fork', { tid: tid, fromTid: fromTid, uid: uid });
|
||||||
|
|||||||
Reference in New Issue
Block a user