mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-15 17:03:59 +00:00
Nutomic
9d26ac2c6f
* 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
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
use activitypub_federation::config::Data;
|
|
use lemmy_api_common::context::LemmyContext;
|
|
use lemmy_db_schema::{newtypes::CommunityId, source::local_site::LocalSite, ListingType};
|
|
use lemmy_utils::{error::LemmyError, ConnectionId};
|
|
use std::str::FromStr;
|
|
|
|
mod list_comments;
|
|
mod list_posts;
|
|
mod read_community;
|
|
mod read_person;
|
|
mod resolve_object;
|
|
mod search;
|
|
|
|
#[async_trait::async_trait]
|
|
pub trait PerformApub {
|
|
type Response: serde::ser::Serialize + Send;
|
|
|
|
async fn perform(
|
|
&self,
|
|
context: &Data<LemmyContext>,
|
|
websocket_id: Option<ConnectionId>,
|
|
) -> Result<Self::Response, LemmyError>;
|
|
}
|
|
|
|
/// Returns default listing type, depending if the query is for frontpage or community.
|
|
fn listing_type_with_default(
|
|
type_: Option<ListingType>,
|
|
local_site: &LocalSite,
|
|
community_id: Option<CommunityId>,
|
|
) -> Result<ListingType, LemmyError> {
|
|
// On frontpage use listing type from param or admin configured default
|
|
let listing_type = if community_id.is_none() {
|
|
type_.unwrap_or(ListingType::from_str(
|
|
&local_site.default_post_listing_type,
|
|
)?)
|
|
} else {
|
|
// inside of community show everything
|
|
ListingType::All
|
|
};
|
|
Ok(listing_type)
|
|
}
|