posts are marked as deleted to preserve array structure
This commit is contained in:
@@ -32,7 +32,6 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.
|
||||
* probably insecure as hell
|
||||
|
||||
# Planned features/todo list
|
||||
* URGENT give each post and user a hard postID to prevent potential issues
|
||||
* edit user (could be on instead of the delete_account page)
|
||||
* user specific RSS feeds
|
||||
* atom
|
||||
|
@@ -306,18 +306,18 @@ app.post("/submit_delete_account", (req,res) => {
|
||||
if (password == users[userID]['hash']) { // password matches
|
||||
console.log(username, "(userID:", userID, ") is trying deleting their account")
|
||||
// Delete the user
|
||||
users.splice(userID,1)
|
||||
users[userID] = {"deleted": true}
|
||||
// Delete all their posts
|
||||
for (let postid = 0; postid < posts.length; postid++) { // loop over all posts
|
||||
if (posts[postid]['userID'] == userID) { // if userID matches
|
||||
posts.splice(postid,1) // delete the post
|
||||
comments.comments.splice(postid,1) // the comments for this post should also be delete
|
||||
posts[postid] = {"deleted": true} // delete the post
|
||||
comments.comments[postid] = {"deleted": true} // the comments for this post should also be deleted
|
||||
}
|
||||
};
|
||||
// Write these changes
|
||||
fs.writeFileSync(`../data/users.json`, `${JSON.stringify(users)}`, 'utf-8');
|
||||
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8');
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
|
||||
res.redirect(301,"/")
|
||||
}
|
||||
else { // password does not match
|
||||
@@ -354,8 +354,8 @@ app.post("/submit_edit", (req,res) => {
|
||||
post['editdate'] = unix_timestamp
|
||||
if (typeof delete_bool != "undefined") {
|
||||
console.log("Deleting post!")
|
||||
posts.splice(postID,1)
|
||||
comments.comments.splice(postID,1)
|
||||
posts[postID] = {"deleted": true}
|
||||
comments.comments[postID] = {"deleted": true}
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments.comments)}\nexport const counter = ${comments.counter}`, 'utf-8');
|
||||
}
|
||||
fs.writeFileSync(`../data/posts.json`, `${JSON.stringify(posts)}`, 'utf-8');
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<h1>
|
||||
<%- user.prettyname %>'s posts
|
||||
<%= user.prettyname %>'s posts
|
||||
</h1>
|
||||
<p><%- converter.makeHtml(user.description) %></p>
|
||||
<%- config.seperator %>
|
||||
|
@@ -9,8 +9,10 @@
|
||||
</div>
|
||||
<div id="posts">
|
||||
<% for (let index = posts.length - 1; index >= 0; index--) { %>
|
||||
<% if (posts[index]["deleted"] != true) { %>
|
||||
<%- include('../posts/timeline', {post: posts[index], index: index, user: users[posts[index].userID]}); %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
<footer>
|
||||
<%- include('../partials/footer'); %>
|
||||
|
Reference in New Issue
Block a user