#8115 - log post owner changes (#8117)

* log post owner changes

* log each post separately

* use map instad of a loop
v1.18.x
Opliko 5 years ago committed by Barış Soner Uşaklı
parent 879acc85ae
commit 740de034fa

@ -25,6 +25,7 @@ events.types = [
'post-delete',
'post-restore',
'post-purge',
'post-change-owner',
'topic-delete',
'topic-restore',
'topic-purge',

@ -163,6 +163,7 @@ module.exports = function (Posts) {
reduceCounters(postsByUser),
updateTopicPosters(postData, toUid),
]);
return postData;
};
async function reduceCounters(postsByUser) {

@ -172,6 +172,17 @@ module.exports = function (SocketPosts) {
throw new Error('[[error:no-privileges]]');
}
await posts.changeOwner(data.pids, data.toUid);
var postData = await posts.changeOwner(data.pids, data.toUid);
var logs = postData.map(({ pid, uid, cid }) => (events.log({
type: 'post-change-owner',
uid: socket.uid,
ip: socket.ip,
targetUid: data.toUid,
pid: pid,
originalUid: uid,
cid: cid,
})));
await Promise.all(logs);
};
};

Loading…
Cancel
Save