Fix ordering when doing a comment_parent type list_comments (#3823)

* Fix ordering when doing a comment_parent type GetPost.

* Fix missing options.
This commit is contained in:
Dessalines 2023-08-07 05:11:07 -04:00 committed by GitHub
parent 66ac8100d9
commit 57cb5637fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -237,8 +237,8 @@ fn queries<'a>() -> Queries<
query = query.filter(nlevel(comment::path).le(depth_limit)); query = query.filter(nlevel(comment::path).le(depth_limit));
// only order if filtering by a post id. DOS potential otherwise and max_depth + !post_id isn't used anyways (afaik) // only order if filtering by a post id, or parent_path. DOS potential otherwise and max_depth + !post_id isn't used anyways (afaik)
if options.post_id.is_some() { if options.post_id.is_some() || options.parent_path.is_some() {
// Always order by the parent path first // Always order by the parent path first
query = query.order_by(subpath(comment::path, 0, -1)); query = query.order_by(subpath(comment::path, 0, -1));
} }

View file

@ -308,7 +308,7 @@ fn queries<'a>() -> Queries<
.unwrap_or(true) .unwrap_or(true)
{ {
// Do not hide read posts when it is a user profile view // Do not hide read posts when it is a user profile view
if !is_profile_view { if !options.is_profile_view {
query = query.filter(post_read::post_id.is_null()); query = query.filter(post_read::post_id.is_null());
} }
} }