-
-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix listing type default value #2796
Conversation
crates/apub/src/api/list_comments.rs
Outdated
let max_depth = data.max_depth; | ||
let saved_only = data.saved_only; | ||
let page = data.page; | ||
let limit = data.limit; | ||
let parent_id = data.parent_id; | ||
|
||
// On frontpage use listing type from param or admin configured default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copy pasted below, might as well use a helper function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I didnt do that before because with community_id and community_actor_id, there would have been too many parameters and it would be awkward. Added helper now.
crates/apub/src/api/list_posts.rs
Outdated
} else { | ||
// inside of community show everything | ||
ListingType::All | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the other place its pasted.
crates/db_views/src/comment_view.rs
Outdated
@@ -167,10 +167,9 @@ impl CommentView { | |||
pub struct CommentQuery<'a> { | |||
#[builder(!default)] | |||
pool: &'a DbPool, | |||
listing_type: Option<ListingType>, | |||
sort: Option<CommentSortType>, | |||
listing_type: ListingType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these aren't optional anymore, you might need to add that builder !default
line to these two.
edit:
To me it makes sense to leave these optional, and move the unwrap_or_default
into the query impls.
crates/db_views/src/post_view.rs
Outdated
@@ -220,11 +220,10 @@ impl PostView { | |||
pub struct PostQuery<'a> { | |||
#[builder(!default)] | |||
pool: &'a DbPool, | |||
listing_type: Option<ListingType>, | |||
sort: Option<SortType>, | |||
listing_type: ListingType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@@ -121,8 +121,8 @@ impl CommunityView { | |||
pub struct CommunityQuery<'a> { | |||
#[builder(!default)] | |||
pool: &'a DbPool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
@@ -176,7 +176,7 @@ impl<'a> CommunityQuery<'a> { | |||
.filter(community::deleted.eq(false)); | |||
} | |||
|
|||
match self.sort.unwrap_or(SortType::Hot) { | |||
match self.sort { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes more sense to me have these optional in the builder, and move the unwrap_or_default to here.
@@ -73,7 +73,7 @@ impl PersonView { | |||
pub struct PersonQuery<'a> { | |||
#[builder(!default)] | |||
pool: &'a DbPool, | |||
sort: Option<SortType>, | |||
sort: SortType, | |||
search_term: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue.
16053bf
to
e9dcd84
Compare
I removed the second commit, apparently its not as easy as I thought. |
The listing type parameter is only meant for the frontpage, but is also applied inside of communities. The result is that this call returns nothing, because it defaults to ListingType::Local: https://fedibb.ml/api/v3/post/list?community_id=3 It needs to be called like this to get any posts: https://fedibb.ml/api/v3/post/list?community_id=3&type_=All This is clearly not expected behaviour, when a community is specified, the listing type should default to All.
e9dcd84
to
3bff89b
Compare
Feel free to merge once you get to the clippy issues. |
I'll see what I can do to fix this woodpecker issue on another PR. |
* Fix listing type default value The listing type parameter is only meant for the frontpage, but is also applied inside of communities. The result is that this call returns nothing, because it defaults to ListingType::Local: https://fedibb.ml/api/v3/post/list?community_id=3 It needs to be called like this to get any posts: https://fedibb.ml/api/v3/post/list?community_id=3&type_=All This is clearly not expected behaviour, when a community is specified, the listing type should default to All. * fix clippy
* Fix listing type default value The listing type parameter is only meant for the frontpage, but is also applied inside of communities. The result is that this call returns nothing, because it defaults to ListingType::Local: https://fedibb.ml/api/v3/post/list?community_id=3 It needs to be called like this to get any posts: https://fedibb.ml/api/v3/post/list?community_id=3&type_=All This is clearly not expected behaviour, when a community is specified, the listing type should default to All. * fix clippy
The listing type parameter is only meant for the frontpage, but is
also applied inside of communities. The result is that this call
returns nothing, because it defaults to ListingType::Local:
https://fedibb.ml/api/v3/post/list?community_id=3
It needs to be called like this to get any posts:
https://fedibb.ml/api/v3/post/list?community_id=3&type_=All
This is clearly not expected behaviour, when a community is
specified, the listing type should default to All.
Also simplified the defaults for db view forms in second commit.