feat: extend activitypubApi.create.note to accept a post object to reduce unnecessary calls to retrieve post summary

This commit is contained in:
Julian Lam
2024-09-05 10:42:44 -04:00
parent 16c8a6523a
commit b63440cb14
2 changed files with 7 additions and 5 deletions

View File

@@ -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);