Made it so if an invalid user or post is loaded, a proper error message is

shown instead of just a nodeJS error message
This commit is contained in:
2025-09-06 23:54:49 +01:00
parent c8af978259
commit e3e5469e1a

View File

@@ -191,24 +191,32 @@ app.get("/", (req,res) => {
app.get("/user/:username", (req, res) => {
const userID = func.get_userID(req.params.username)
console.log(userID)
console.log(users[userID].prettyname)
res.render("pages/user",
{
config,
locale,
posts,
user: users[userID],
userID: userID,
comments: comments.comments,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
})
if (userID != -1) {
res.render("pages/user",
{
config,
locale,
posts,
user: users[userID],
userID: userID,
comments: comments.comments,
fromUnixTime: fromUnixTime,
format: format,
getUnixTime: getUnixTime,
func,
})
}
else if (userID == -1) {
res.render("partials/message",
{
message: locale.user_doesnt_exist,
config,
})
}
}); // /user/:username
app.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index
if (posts[postID]["deleted"] == true) {
if (postID > posts.length-1 || posts[postID]["deleted"] == true) {
res.render("partials/message", {
message: locale.post_doesnt_exist,
config,