mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +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,
|
tid: tid,
|
||||||
content: content,
|
content: content,
|
||||||
timestamp: timestamp,
|
timestamp: timestamp,
|
||||||
_activitypub,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (data.toPid) {
|
if (data.toPid) {
|
||||||
@@ -48,8 +47,7 @@ module.exports = function (Posts) {
|
|||||||
postData.handle = data.handle;
|
postData.handle = data.handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = await plugins.hooks.fire('filter:post.create', { post: postData, data: data });
|
({ post: postData } = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }));
|
||||||
postData = result.post;
|
|
||||||
await db.setObject(`post:${postData.pid}`, postData);
|
await db.setObject(`post:${postData.pid}`, postData);
|
||||||
|
|
||||||
const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']);
|
const topicData = await topics.getTopicFields(tid, ['cid', 'pinned']);
|
||||||
@@ -66,9 +64,9 @@ module.exports = function (Posts) {
|
|||||||
Posts.uploads.sync(postData.pid),
|
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;
|
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;
|
return result.post;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ module.exports = function (Posts) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Posts.edit = async function (data) {
|
Posts.edit = async function (data) {
|
||||||
|
const { _activitypub } = data;
|
||||||
const canEdit = await privileges.posts.canEdit(data.pid, data.uid);
|
const canEdit = await privileges.posts.canEdit(data.pid, data.uid);
|
||||||
if (!canEdit.flag) {
|
if (!canEdit.flag) {
|
||||||
throw new Error(canEdit.message);
|
throw new Error(canEdit.message);
|
||||||
@@ -89,7 +90,7 @@ module.exports = function (Posts) {
|
|||||||
});
|
});
|
||||||
await topics.syncBacklinks(returnPostData);
|
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));
|
require('./cache').del(String(postData.pid));
|
||||||
pubsub.publish('post:edit', String(postData.pid));
|
pubsub.publish('post:edit', String(postData.pid));
|
||||||
|
|||||||
Reference in New Issue
Block a user