mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: accidental saving of ephemeral _activitypub object into db, should plumb into hooks only
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user