feat: closes #10018

isekai-main
Barış Soner Uşaklı 3 years ago
parent 9239582e36
commit 1e53552874

@ -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 });

Loading…
Cancel
Save