mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: extend activitypubApi.create.note to accept a post object to reduce unnecessary calls to retrieve post summary
This commit is contained in:
@@ -144,10 +144,12 @@ async function buildRecipients(object, { pid, uid }) {
|
||||
};
|
||||
}
|
||||
|
||||
activitypubApi.create.note = enabledCheck(async (caller, { pid }) => {
|
||||
const post = (await posts.getPostSummaryByPids([pid], caller.uid, { stripTags: false })).pop();
|
||||
activitypubApi.create.note = enabledCheck(async (caller, { pid, post }) => {
|
||||
if (!post) {
|
||||
return;
|
||||
post = (await posts.getPostSummaryByPids([pid], caller.uid, { stripTags: false })).pop();
|
||||
if (!post) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const allowed = await privileges.posts.can('topics:read', pid, activitypub._constants.uid);
|
||||
|
||||
@@ -107,7 +107,7 @@ topicsAPI.reply = async function (caller, data) {
|
||||
}
|
||||
|
||||
const postData = await topics.reply(payload); // postData seems to be a subset of postObj, refactor?
|
||||
const postObj = await posts.getPostSummaryByPids([postData.pid], caller.uid, {});
|
||||
const postObj = await posts.getPostSummaryByPids([postData.pid], caller.uid, {}); // standardized API response
|
||||
|
||||
const result = {
|
||||
posts: [postData],
|
||||
@@ -123,7 +123,7 @@ topicsAPI.reply = async function (caller, data) {
|
||||
}
|
||||
|
||||
socketHelpers.notifyNew(caller.uid, 'newPost', result);
|
||||
activitypubApi.create.note(caller, { pid: postData.pid });
|
||||
activitypubApi.create.note(caller, { post: postObj[0] });
|
||||
|
||||
return postObj[0];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user