]> Untitled Git - lemmy.git/blob - crates/apub/src/api/mod.rs
Replace Option<bool> with bool for PostQuery and CommentQuery (#3819) (#3857)
[lemmy.git] / crates / apub / src / api / mod.rs
1 use lemmy_db_schema::{newtypes::CommunityId, source::local_site::LocalSite, ListingType};
2 use lemmy_utils::error::LemmyError;
3
4 pub mod list_comments;
5 pub mod list_posts;
6 pub mod read_community;
7 pub mod read_person;
8 pub mod resolve_object;
9 pub mod search;
10
11 /// Returns default listing type, depending if the query is for frontpage or community.
12 fn listing_type_with_default(
13   type_: Option<ListingType>,
14   local_site: &LocalSite,
15   community_id: Option<CommunityId>,
16 ) -> Result<ListingType, LemmyError> {
17   // On frontpage use listing type from param or admin configured default
18   let listing_type = if community_id.is_none() {
19     type_.unwrap_or(local_site.default_post_listing_type)
20   } else {
21     // inside of community show everything
22     ListingType::All
23   };
24   Ok(listing_type)
25 }