reply chain fixes, refactoring
This commit is contained in:
parent
f0782b0472
commit
93027bfd09
4 changed files with 42 additions and 43 deletions
27
lib.js
27
lib.js
|
@ -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 };
|
Loading…
Add table
Add a link
Reference in a new issue