1 use activitypub_federation::config::Data;
2 use lemmy_api_common::context::LemmyContext;
3 use lemmy_db_schema::{newtypes::CommunityId, source::local_site::LocalSite, ListingType};
4 use lemmy_utils::{error::LemmyError, ConnectionId};
14 #[async_trait::async_trait]
15 pub trait PerformApub {
16 type Response: serde::ser::Serialize + Send;
20 context: &Data<LemmyContext>,
21 websocket_id: Option<ConnectionId>,
22 ) -> Result<Self::Response, LemmyError>;
25 /// Returns default listing type, depending if the query is for frontpage or community.
26 fn listing_type_with_default(
27 type_: Option<ListingType>,
28 local_site: &LocalSite,
29 community_id: Option<CommunityId>,
30 ) -> Result<ListingType, LemmyError> {
31 // On frontpage use listing type from param or admin configured default
32 let listing_type = if community_id.is_none() {
33 type_.unwrap_or(ListingType::from_str(
34 &local_site.default_post_listing_type,
37 // inside of community show everything