mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
refactor(topic-events): fire topic event logging in topics/tools instead, pass uid into payload
This commit is contained in:
@@ -63,11 +63,6 @@ exports.doTopicAction = async function (action, event, caller, { tids }) {
|
||||
};
|
||||
|
||||
async function logTopicAction(action, req, tid, title) {
|
||||
// No 'purge' topic event (since topic is now gone)
|
||||
if (action !== 'purge') {
|
||||
await topics.events.log(tid, { type: action });
|
||||
}
|
||||
|
||||
// Only log certain actions to system event log
|
||||
var actionsToLog = ['delete', 'restore', 'purge'];
|
||||
if (!actionsToLog.includes(action)) {
|
||||
|
||||
@@ -44,6 +44,7 @@ module.exports = function (Topics) {
|
||||
} else {
|
||||
await Topics.restore(data.topicData.tid);
|
||||
}
|
||||
await Topics.events.log(tid, { type: isDelete ? 'delete' : 'restore', uid });
|
||||
|
||||
data.topicData.deleted = data.isDelete ? 1 : 0;
|
||||
|
||||
@@ -94,6 +95,7 @@ module.exports = function (Topics) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
}
|
||||
await Topics.setTopicField(tid, 'locked', lock ? 1 : 0);
|
||||
await Topics.events.log(tid, { type: lock ? 'lock' : 'unlock', uid });
|
||||
topicData.isLocked = lock; // deprecate in v2.0
|
||||
topicData.locked = lock;
|
||||
|
||||
@@ -152,6 +154,7 @@ module.exports = function (Topics) {
|
||||
|
||||
const promises = [
|
||||
Topics.setTopicField(tid, 'pinned', pin ? 1 : 0),
|
||||
Topics.events.log(tid, { type: pin ? 'pin' : 'unpin', uid }),
|
||||
];
|
||||
if (pin) {
|
||||
promises.push(db.sortedSetAdd('cid:' + topicData.cid + ':tids:pinned', Date.now(), tid));
|
||||
|
||||
Reference in New Issue
Block a user