Changed how comments are stored and how data is retrieved
This commit is contained in:
@@ -33,7 +33,7 @@ router.get("/", (req,res) => {
|
||||
// Users
|
||||
router.get("/user/:username", (req, res) => {
|
||||
const userID = func.get_userID(req.params.username)
|
||||
let user = data.getdata('users', userID)
|
||||
let user = data.getdata('users', 'id', userID)
|
||||
if (userID != -1) {
|
||||
res.render("pages/user",
|
||||
{
|
||||
@@ -61,7 +61,7 @@ router.get("/user/:username", (req, res) => {
|
||||
// Posts
|
||||
router.get("/post/:post_index", (req, res) => {
|
||||
const postID = parseInt(req.params.post_index)
|
||||
let post = data.getdata('posts', postID)
|
||||
let post = data.getdata('posts','id', postID)
|
||||
if (post == 1) { // data.getdata returns error code 1 if nothing is available
|
||||
res.render("partials/message", {
|
||||
message: locale.post_doesnt_exist,
|
||||
@@ -69,7 +69,7 @@ router.get("/post/:post_index", (req, res) => {
|
||||
})
|
||||
}
|
||||
if (config.enable_hitcount) {
|
||||
data.increment_hitcount(postID)
|
||||
data.increment_hitcount(postID)
|
||||
}
|
||||
if (typeof post["deleted"] == "undefined" || post["deleted"] == false) {
|
||||
res.render("pages/post",
|
||||
@@ -78,8 +78,8 @@ router.get("/post/:post_index", (req, res) => {
|
||||
locale,
|
||||
post,
|
||||
postID,
|
||||
user: data.getdata('users', post.userID),
|
||||
comments: data.getdata('comments', postID),
|
||||
user: data.getdata('users','id', post.userID),
|
||||
comments: data.getdata('comments','id', postID)["comments"],
|
||||
fromUnixTime,
|
||||
format,
|
||||
getUnixTime,
|
||||
@@ -117,7 +117,7 @@ router.get("/comment/:postID-:commentID", (req,res) => {
|
||||
const commentID = parseInt(req.params.commentID);
|
||||
const postID = parseInt(req.params.postID);
|
||||
|
||||
let posts_comments = data.getdata('comments', postID)
|
||||
let posts_comments = data.getdata('comments', 'id', postID)["comments"]
|
||||
let comment = 1
|
||||
// For loop to find the comment with matching ID
|
||||
posts_comments.forEach((current_comment, index) => {
|
||||
|
||||
Reference in New Issue
Block a user