diff --git a/src/posts/create.js b/src/posts/create.js index c876c53660..87213d131c 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -35,7 +35,6 @@ module.exports = function (Posts) { tid: tid, content: content, timestamp: timestamp, - _activitypub, }; if (data.toPid) { @@ -48,8 +47,7 @@ module.exports = function (Posts) { postData.handle = data.handle; } - let result = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }); - postData = result.post; + ({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data })); await db.setObject(`post:${postData.pid}`, postData); const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']); @@ -66,9 +64,9 @@ module.exports = function (Posts) { Posts.uploads.sync(postData.pid), ]); - result = await plugins.hooks.fire('filter:post.get', { post: postData, uid: data.uid }); + const result = await plugins.hooks.fire('filter:post.get', { post: postData, uid: data.uid }); result.post.isMain = isMain; - plugins.hooks.fire('action:post.save', { post: _.clone(result.post) }); + plugins.hooks.fire('action:post.save', { post: { ...result.post, _activitypub } }); return result.post; }; diff --git a/src/posts/edit.js b/src/posts/edit.js index a63f34cc48..64c658ca02 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -20,6 +20,7 @@ module.exports = function (Posts) { }); Posts.edit = async function (data) { + const { _activitypub } = data; const canEdit = await privileges.posts.canEdit(data.pid, data.uid); if (!canEdit.flag) { throw new Error(canEdit.message); @@ -89,7 +90,7 @@ module.exports = function (Posts) { }); await topics.syncBacklinks(returnPostData); - plugins.hooks.fire('action:post.edit', { post: _.clone(returnPostData), data: data, uid: data.uid }); + plugins.hooks.fire('action:post.edit', { post: { ...returnPostData, _activitypub }, data: data, uid: data.uid }); require('./cache').del(String(postData.pid)); pubsub.publish('post:edit', String(postData.pid));