reply chain fixes, refactoring

This commit is contained in:
biglyderv 2025-02-26 19:50:37 -05:00
parent f0782b0472
commit 93027bfd09
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
4 changed files with 42 additions and 43 deletions

27
lib.js
View file

@ -9,4 +9,29 @@ function apiStat(res, next, message, success = false, redirect = '/') {
next();
}
export { importRouters, apiStat };
async function replyIterator(replies, db) {
for (let reply of replies) {
if (reply.childType == 'hub') {
reply.comment = { type: reply.childType, id: reply.childId, content: `The ${reply.childId} hub.`, username: false, date: undefined };
continue;
} else if (reply.childType == 'users') {
reply.comment = { type: reply.childType, id: reply.childId, content: `User ${reply.childId}'s wall.`, username: false, date: undefined };
continue;
}
let dat = await db.all('SELECT * FROM comment WHERE id = ?', [
reply.childId
]);
if (reply.childType != 'comment' || dat.length < 1) {
reply.comment = 'fail';
continue;
}
reply.comment = dat[0];
reply.comment.type = reply.childType;
//reply.comment.id = reply.childId;
}
return replies;
}
export { importRouters, apiStat, replyIterator };