feat: new admin events, closes #10405

This commit is contained in:
Barış Soner Uşaklı
2022-03-18 15:54:40 -04:00
parent 55be42026c
commit 421ba6e1a2
7 changed files with 89 additions and 1 deletions

View File

@@ -70,6 +70,18 @@ postsAPI.edit = async function (caller, data) {
if (editResult.topic.isMainPost) {
await topics.thumbs.migrate(data.uuid, editResult.topic.tid);
}
const selfPost = parseInt(caller.uid, 10) === parseInt(editResult.post.uid, 10);
if (!selfPost && editResult.post.changed) {
await events.log({
type: `post-edit`,
uid: caller.uid,
ip: caller.ip,
pid: editResult.post.pid,
oldContent: editResult.post.oldContent,
newContent: editResult.post.newContent,
});
}
if (editResult.topic.renamed) {
await events.log({
type: 'topic-rename',
@@ -227,6 +239,13 @@ postsAPI.move = async function (caller, data) {
const [postDeleted, topicDeleted] = await Promise.all([
posts.getPostField(data.pid, 'deleted'),
topics.getTopicField(data.tid, 'deleted'),
await events.log({
type: `post-move`,
uid: caller.uid,
ip: caller.ip,
pid: data.pid,
toTid: data.tid,
}),
]);
if (!postDeleted && !topicDeleted) {