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};
13 #[async_trait::async_trait]
14 pub trait PerformApub {
15 type Response: serde::ser::Serialize + Send;
19 context: &Data<LemmyContext>,
20 websocket_id: Option<ConnectionId>,
21 ) -> Result<Self::Response, LemmyError>;
24 /// Returns default listing type, depending if the query is for frontpage or community.
25 fn listing_type_with_default(
26 type_: Option<ListingType>,
27 local_site: &LocalSite,
28 community_id: Option<CommunityId>,
29 ) -> Result<ListingType, LemmyError> {
30 // On frontpage use listing type from param or admin configured default
31 let listing_type = if community_id.is_none() {
32 type_.unwrap_or(local_site.default_post_listing_type)
34 // inside of community show everything