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

@ -22,20 +22,24 @@ router.get('/:id', async (req, res, next) => {
for (let reply of replies) {
let dat = await db.all('SELECT * FROM comment WHERE id = ?', [
reply.parentId
reply.childId
]);
if (reply.parentType != 'comment' || dat.length < 1) {
reply.comment = {username: 'fail', date: 'fail', content: 'fail'};
if (reply.childType != 'comment' || dat.length < 1) {
reply.comment = 'fail'
continue;
}
reply.comment = dat[0];
reply.comment.id = reply.childId;
reply.comment.type = reply.childType;
}
replies = replies.filter(x => x.comment != 'fail');
console.log(replies)
res.ctx.mainPage = 'commenter'
res.ctx.mainCtx = {
replies,
opLink: `/comments/${req.params.id}`
replies
}
next();
})