mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: closes #10018
This commit is contained in:
@@ -60,7 +60,7 @@ Events._types = {
|
||||
},
|
||||
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) => {
|
||||
const topics = require('.');
|
||||
const { type } = payload;
|
||||
const now = Date.now();
|
||||
const timestamp = payload.timestamp || Date.now();
|
||||
|
||||
if (!Events._types.hasOwnProperty(type)) {
|
||||
throw new Error(`[[error:topic-event-unrecognized, ${type}]]`);
|
||||
@@ -171,12 +171,12 @@ Events.log = async (tid, payload) => {
|
||||
|
||||
await Promise.all([
|
||||
db.setObject(`topicEvent:${eventId}`, payload),
|
||||
db.sortedSetAdd(`topic:${tid}:events`, now, eventId),
|
||||
db.sortedSetAdd(`topic:${tid}:events`, timestamp, eventId),
|
||||
]);
|
||||
|
||||
let events = await modifyEvent({
|
||||
eventIds: [eventId],
|
||||
timestamps: [now],
|
||||
timestamps: [timestamp],
|
||||
events: [payload],
|
||||
});
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = function (Topics) {
|
||||
downvotes: postData.downvotes,
|
||||
}),
|
||||
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 });
|
||||
|
||||
Reference in New Issue
Block a user