d8722b6e91
* Adding diesel enums for SortType and ListingType - Uses diesel-derive-enum. - Adds diesel.toml , so we can again use the auto-generated schema.rs - Fixes a lot of DB null issues and column ordering issues. - Fixes #1136 - Also replaces RegistrationMode boilerplate. * Fixing unit tests 1. * Remove comment line. * Before patch. * Before again. * Using patch file to fix diesel_ltree issue with diesel.toml * Adding some yalc ignores * Fixing RegistrationMode enums * Adding woodpecker diesel schema check. * Try adding openssl 1. * Try using diesel-cli image 1 * Try using diesel-cli image 2 * Try using diesel-cli image 3 * Try using diesel-cli image 4 * Try using diesel-cli image 5 * Try using diesel-cli image 6 * Try using diesel-cli image 7 * Try using diesel-cli image 8 * Try using diesel-cli image 9 * Try using diesel-cli image 10 * Try using diesel-cli image 11 * Try using diesel-cli image 12 * Try using diesel-cli image 13
38 lines
1.1 KiB
Rust
38 lines
1.1 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};
|
|
|
|
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(local_site.default_post_listing_type)
|
|
} else {
|
|
// inside of community show everything
|
|
ListingType::All
|
|
};
|
|
Ok(listing_type)
|
|
}
|