X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi_crud%2Fsrc%2Fpost%2Flist.rs;h=154faaaafedf9dcc6ea0c8b5f709655516ccf5ed;hb=00b0b26dfa0f79fdb4867fd4545b119ca81a521b;hp=8a714e992883c35a106438e0261cdc894494b30e;hpb=24be9f2cd5afefc2bb1f88021b6e73ffe9ffacf0;p=lemmy.git diff --git a/crates/api_crud/src/post/list.rs b/crates/api_crud/src/post/list.rs index 8a714e99..154faaaa 100644 --- a/crates/api_crud/src/post/list.rs +++ b/crates/api_crud/src/post/list.rs @@ -4,12 +4,12 @@ use lemmy_api_common::{ blocking, check_private_instance, get_local_user_view_from_jwt_opt, - post::*, + post::{GetPosts, GetPostsResponse}, }; use lemmy_apub::{fetcher::resolve_actor_identifier, objects::community::ApubCommunity}; use lemmy_db_schema::{ from_opt_str_to_opt_enum, - source::community::Community, + source::{community::Community, site::Site}, traits::DeleteableOrRemoveable, ListingType, SortType, @@ -17,6 +17,7 @@ use lemmy_db_schema::{ use lemmy_db_views::post_view::PostQueryBuilder; use lemmy_utils::{ConnectionId, LemmyError}; use lemmy_websocket::LemmyContext; +use std::str::FromStr; #[async_trait::async_trait(?Send)] impl PerformCrud for GetPosts { @@ -46,7 +47,13 @@ impl PerformCrud for GetPosts { .map(|t| t.local_user.show_read_posts); let sort: Option = from_opt_str_to_opt_enum(&data.sort); - let listing_type: Option = from_opt_str_to_opt_enum(&data.type_); + let listing_type: ListingType = match from_opt_str_to_opt_enum(&data.type_) { + Some(l) => l, + None => { + let site = blocking(context.pool(), Site::read_local_site).await??; + ListingType::from_str(&site.default_post_listing_type)? + } + }; let page = data.page; let limit = data.limit;