Post doesn't exist page

This commit is contained in:
2025-08-01 23:21:43 +01:00
parent 88b198365d
commit cdfc5f2c30
3 changed files with 36 additions and 22 deletions

View File

@@ -186,19 +186,31 @@ app.get("/user/:username", (req, res) => {
}); // /user/:username
app.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index
res.render("pages/post",
{
if (posts[postID]["deleted"] == true) {
res.render("partials/message", {
message: config.string.post_doesnt_exist,
config,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
converter,
})
}
else if (typeof posts[postID]["deleted"] == "undefined" || posts[postID]["deleted"] == false) {
res.render("pages/post",
{
config,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
converter,
})
}
else {
console.log("Error loading page")
res.redirect(301,"/")
}
}); // /post/:post_index
app.get("/tag/:tag", (req,res) => {
const tag = req.params.tag
@@ -431,15 +443,15 @@ app.post("/submit_edit_user", (req,res) => {
}
}); // /submit_delete_account
app.post("/submit_edit_post", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = req.body.title
const content = req.body.content
const tags = req.body.tags.split(',');
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = req.body.title
const content = req.body.content
const tags = req.body.tags.split(',');
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
if (users[userID]['hash'] == password) { // password matches
let post = posts[postID]