wall context
This commit is contained in:
parent
d65c737a6e
commit
f0782b0472
8 changed files with 33 additions and 11 deletions
|
@ -29,6 +29,7 @@ router.get('/:id', async (req, res, next) => {
|
|||
continue;
|
||||
}
|
||||
reply.comment = dat[0];
|
||||
reply.comment.idOriginal = reply.comment.id;
|
||||
reply.comment.id = reply.childId;
|
||||
reply.comment.type = reply.childType;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import { importRouters } from "../lib.js";
|
|||
import multer from "multer";
|
||||
import cookieParser from "cookie-parser";
|
||||
import { initDb } from "../db.js";
|
||||
import express from "express";
|
||||
|
||||
let db = await initDb();
|
||||
|
||||
|
@ -89,8 +90,9 @@ async function doInit(app) {
|
|||
|
||||
doAliases(app);
|
||||
|
||||
app.use(express.static('public'));
|
||||
app.use('/uploads', express.static('uploads'));
|
||||
app.use(auther)
|
||||
|
||||
app.use(initr)
|
||||
|
||||
app.use('/api/form', upload.none());
|
||||
|
|
|
@ -38,21 +38,31 @@ router.get('/get/:type/:id/:num', async (req, res, next) => {
|
|||
]);
|
||||
|
||||
replies.splice(0, 0, {
|
||||
childType: 'comment',
|
||||
childType: req.params.type,
|
||||
childId: req.params.id
|
||||
})
|
||||
|
||||
//TODO: make iterator
|
||||
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;
|
||||
//reply.comment.id = reply.childId;
|
||||
}
|
||||
|
||||
let comment = replies.splice(0, 1)[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue