Comment submission works
I fixed the comment submission to use the new way of storing comments and their counter. I also fixed the AI-consent field in en-US because I accidently had · instead of spaces (from when I copy pasted from vim) Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
@@ -16,23 +16,24 @@ const router = express.Router();
|
||||
////////////////////// Form actions /////////////////////////
|
||||
router.post("/submit_comment", (req,res) => {
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
const postID = parseInt(req.body.post_index)
|
||||
const content = func.escape_input(req.body.content)
|
||||
let name = func.escape_input(req.body.name)
|
||||
if (name == "") {
|
||||
name = config.default_commenter_username
|
||||
}
|
||||
|
||||
let comments = data.getdata('comments')
|
||||
|
||||
new_comment = {
|
||||
"name": name,
|
||||
"content": func.escape_input(req.body.content),
|
||||
"id": data.getdata('other_data').comment_counter,
|
||||
"content": content,
|
||||
"id": comments[postID].length,
|
||||
"pubdate": unix_timestamp,
|
||||
"postID": req.body.post_index,
|
||||
"postID": postID,
|
||||
};
|
||||
let other_data = data.getdata('other_data')
|
||||
other_data.comment_counter += 1;
|
||||
let comments = data.getdata('comments')
|
||||
comments[req.body.post_index].push(new_comment);
|
||||
comments[postID].push(new_comment);
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
|
||||
fs.writeFileSync('../data/data.json', JSON.stringify(other_data), 'utf-8');
|
||||
|
||||
res.redirect(301,`/post/${req.body.post_index}`)
|
||||
}); // /submit_comment
|
||||
|
Reference in New Issue
Block a user