#![recursion_limit = "256"] #[cfg(feature = "full")] #[macro_use] extern crate diesel; #[cfg(feature = "full")] #[macro_use] extern crate diesel_derive_newtype; #[cfg(feature = "full")] #[macro_use] extern crate diesel_derive_enum; // this is used in tests #[cfg(feature = "full")] #[macro_use] extern crate diesel_migrations; #[cfg(feature = "full")] #[macro_use] extern crate async_trait; pub mod aggregates; #[cfg(feature = "full")] pub mod impls; pub mod newtypes; #[cfg(feature = "full")] #[rustfmt::skip] #[allow(clippy::wildcard_imports)] pub mod schema; #[cfg(feature = "full")] pub mod aliases { use crate::schema::{community_moderator, person}; diesel::alias!( person as person1: Person1, person as person2: Person2, community_moderator as community_moderator1: CommunityModerator1 ); } pub mod source; #[cfg(feature = "full")] pub mod traits; #[cfg(feature = "full")] pub mod utils; use serde::{Deserialize, Serialize}; use strum_macros::{Display, EnumString}; #[cfg(feature = "full")] use ts_rs::TS; #[derive( EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( feature = "full", ExistingTypePath = "crate::schema::sql_types::SortTypeEnum" )] #[cfg_attr(feature = "full", DbValueStyle = "verbatim")] #[cfg_attr(feature = "full", ts(export))] // TODO add the controversial and scaled rankings to the doc below /// The post sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html pub enum SortType { #[default] Active, Hot, New, Old, TopDay, TopWeek, TopMonth, TopYear, TopAll, MostComments, NewComments, TopHour, TopSixHour, TopTwelveHour, TopThreeMonths, TopSixMonths, TopNineMonths, Controversial, Scaled, } #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// The comment sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html pub enum CommentSortType { Hot, Top, New, Old, Controversial, } #[derive( EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( feature = "full", ExistingTypePath = "crate::schema::sql_types::ListingTypeEnum" )] #[cfg_attr(feature = "full", DbValueStyle = "verbatim")] #[cfg_attr(feature = "full", ts(export))] /// A listing type for post and comment list fetches. pub enum ListingType { /// Content from your own site, as well as all connected / federated sites. All, /// Content from your site only. #[default] Local, /// Content only from communities you've subscribed to. Subscribed, /// Content that you can moderate (because you are a moderator of the community it is posted to) ModeratorView, } #[derive( EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( feature = "full", ExistingTypePath = "crate::schema::sql_types::RegistrationModeEnum" )] #[cfg_attr(feature = "full", DbValueStyle = "verbatim")] #[cfg_attr(feature = "full", ts(export))] /// The registration mode for your site. Determines what happens after a user signs up. pub enum RegistrationMode { /// Closed to public. Closed, /// Open, but pending approval of a registration application. RequireApplication, /// Open to all. #[default] Open, } #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( feature = "full", ExistingTypePath = "crate::schema::sql_types::PostListingModeEnum" )] #[cfg_attr(feature = "full", DbValueStyle = "verbatim")] #[cfg_attr(feature = "full", ts(export))] /// A post-view mode that changes how multiple post listings look. pub enum PostListingMode { /// A compact, list-type view. List, /// A larger card-type view. Card, /// A smaller card-type view, usually with images as thumbnails SmallCard, } #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// The type of content returned from a search. pub enum SearchType { All, Comments, Posts, Communities, Users, Url, } #[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// A type / status for a community subscribe. pub enum SubscribedType { Subscribed, NotSubscribed, Pending, } #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// A list of possible types for the various modlog actions. pub enum ModlogActionType { All, ModRemovePost, ModLockPost, ModFeaturePost, ModRemoveComment, ModRemoveCommunity, ModBanFromCommunity, ModAddCommunity, ModTransferCommunity, ModAdd, ModBan, ModHideCommunity, AdminPurgePerson, AdminPurgeCommunity, AdminPurgePost, AdminPurgeComment, } #[derive( EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq, )] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] /// The feature type for a post. pub enum PostFeatureType { #[default] /// Features to the top of your site. Local, /// Features to the top of the community. Community, } #[derive( EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default, )] #[cfg_attr(feature = "full", derive(DbEnum, TS))] #[cfg_attr( feature = "full", ExistingTypePath = "crate::schema::sql_types::CommunityVisibility" )] #[cfg_attr(feature = "full", DbValueStyle = "verbatim")] #[cfg_attr(feature = "full", ts(export))] /// Defines who can browse and interact with content in a community. /// /// TODO: Also use this to define private communities pub enum CommunityVisibility { /// Public community, any local or federated user can interact. #[default] Public, /// Unfederated community, only local users can interact. LocalOnly, } /// Wrapper for assert_eq! macro. Checks that vec matches the given length, and prints the /// vec on failure. #[macro_export] macro_rules! assert_length { ($len:expr, $vec:expr) => {{ assert_eq!($len, $vec.len(), "Vec has wrong length: {:?}", $vec) }}; }