comments and replies work now

This commit is contained in:
biglyderv 2025-02-26 01:40:27 -05:00
parent 11147482d2
commit 9e5989825f
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
6 changed files with 102 additions and 10 deletions

View file

@ -38,18 +38,28 @@ router.get('/get/:type/:id/:num', async (req, res, next) => {
]);
for (let reply of replies) {
if (reply.childType != 'comment') 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;
}
replies = replies.filter(x => x.comment != 'fail');
res.ctx.mainPage = 'replies'
res.ctx.mainCtx = {
page: req.params.num,
replies,
opLink: `/${req.params.type}/${req.params.id}`
opLink: `/${req.params.type}/${req.params.id}`,
type: req.params.type,
id: req.params.id
}
next();
})