mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 16:00:26 +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) {
|
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
|
// Only log certain actions to system event log
|
||||||
var actionsToLog = ['delete', 'restore', 'purge'];
|
var actionsToLog = ['delete', 'restore', 'purge'];
|
||||||
if (!actionsToLog.includes(action)) {
|
if (!actionsToLog.includes(action)) {
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ module.exports = function (Topics) {
|
|||||||
} else {
|
} else {
|
||||||
await Topics.restore(data.topicData.tid);
|
await Topics.restore(data.topicData.tid);
|
||||||
}
|
}
|
||||||
|
await Topics.events.log(tid, { type: isDelete ? 'delete' : 'restore', uid });
|
||||||
|
|
||||||
data.topicData.deleted = data.isDelete ? 1 : 0;
|
data.topicData.deleted = data.isDelete ? 1 : 0;
|
||||||
|
|
||||||
@@ -94,6 +95,7 @@ module.exports = function (Topics) {
|
|||||||
throw new Error('[[error:no-privileges]]');
|
throw new Error('[[error:no-privileges]]');
|
||||||
}
|
}
|
||||||
await Topics.setTopicField(tid, 'locked', lock ? 1 : 0);
|
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.isLocked = lock; // deprecate in v2.0
|
||||||
topicData.locked = lock;
|
topicData.locked = lock;
|
||||||
|
|
||||||
@@ -152,6 +154,7 @@ module.exports = function (Topics) {
|
|||||||
|
|
||||||
const promises = [
|
const promises = [
|
||||||
Topics.setTopicField(tid, 'pinned', pin ? 1 : 0),
|
Topics.setTopicField(tid, 'pinned', pin ? 1 : 0),
|
||||||
|
Topics.events.log(tid, { type: pin ? 'pin' : 'unpin', uid }),
|
||||||
];
|
];
|
||||||
if (pin) {
|
if (pin) {
|
||||||
promises.push(db.sortedSetAdd('cid:' + topicData.cid + ':tids:pinned', Date.now(), tid));
|
promises.push(db.sortedSetAdd('cid:' + topicData.cid + ':tids:pinned', Date.now(), tid));
|
||||||
|
|||||||
Reference in New Issue
Block a user