refactor: get rid of post.exists check, if post doesnt exist content is falsy

This commit is contained in:
Barış Soner Uşaklı
2025-10-30 20:34:01 -04:00
parent b5ea20898e
commit 179440372a

View File

@@ -184,9 +184,6 @@ module.exports = function (Topics) {
.filter(p => p && p.hasOwnProperty('toPid') && (activitypub.helpers.isUri(p.toPid) || utils.isNumber(p.toPid)))
.map(postObj => postObj.toPid);
const exists = await posts.exists(parentPids);
parentPids = parentPids.filter((_, idx) => exists[idx]);
if (!parentPids.length) {
return;
}
@@ -212,7 +209,7 @@ module.exports = function (Topics) {
parentPost.content = foundPost.content;
return;
}
parentPost = await posts.parsePost(parentPost);
await posts.parsePost(parentPost);
}));
const parents = {};
@@ -230,7 +227,7 @@ module.exports = function (Topics) {
});
postData.forEach((post) => {
if (parents[post.toPid]) {
if (parents[post.toPid] && parents[post.toPid].content) {
post.parent = parents[post.toPid];
}
});