added parent id to posts
This commit is contained in:
@@ -81,12 +81,9 @@ public class Routes {
|
||||
// create a post from the author id
|
||||
JodelPost post = new JodelPost(rs);
|
||||
|
||||
// get the posts parent
|
||||
long parent = rs.getLong("parent");
|
||||
|
||||
// check if the parent is the own id
|
||||
// if it is, it is a post
|
||||
if (parent == post.id) {
|
||||
if (!post.isComment()) {
|
||||
// add the post to the posts
|
||||
posts.add(post);
|
||||
}
|
||||
@@ -95,7 +92,7 @@ public class Routes {
|
||||
// iterate over all posts
|
||||
for (JodelPost p : posts) {
|
||||
// try to add the post to a parent
|
||||
p.addComment(post, parent);
|
||||
p.addComment(post);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +197,7 @@ public class Routes {
|
||||
// else it is a comment
|
||||
else {
|
||||
// try to add the post to parent
|
||||
root_post.ifPresent(root -> root.addComment(post, parent));
|
||||
root_post.ifPresent(root -> root.addComment(post));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +284,14 @@ public class Routes {
|
||||
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "Database is offline");
|
||||
}
|
||||
|
||||
// fill missing post values
|
||||
if (post.parent.isEmpty()) post.parent = Optional.of(post.id);
|
||||
post.reactions = new Reactions(0, 0);
|
||||
post.reaction = Optional.empty();
|
||||
|
||||
// anonymize code
|
||||
post.anonymize(Optional.empty());
|
||||
|
||||
return post;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user