feat: log all post edits to the event log, return eid when logging events, plumb eid into Update(Note) to federate out as a unique id

This commit is contained in:
Julian Lam
2024-03-13 15:27:59 -04:00
parent 0bfdbb6a5c
commit 83392f3ca2
3 changed files with 11 additions and 6 deletions

View File

@@ -112,16 +112,16 @@ 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({
let eid;
if (editResult.post.changed) {
({ eid } = 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) {
@@ -140,7 +140,9 @@ postsAPI.edit = async function (caller, data) {
if (!editResult.post.deleted) {
websockets.in(`topic_${editResult.topic.tid}`).emit('event:post_edited', editResult);
await require('.').activitypub.update.note(caller, { post: postObj[0] });
if (eid) {
await require('.').activitypub.update.note(caller, { post: postObj[0], eid });
}
return returnData;
}