lemmy/crates/db_schema/src/lib.rs

154 lines
3.4 KiB
Rust
Raw Normal View History

#![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;
2021-10-16 13:33:38 +00:00
// this is used in tests
#[cfg(feature = "full")]
2021-10-16 13:33:38 +00:00
#[macro_use]
extern crate diesel_migrations;
#[cfg(feature = "full")]
2022-11-09 10:05:00 +00:00
#[macro_use]
extern crate async_trait;
2021-10-16 13:33:38 +00:00
pub mod aggregates;
#[cfg(feature = "full")]
2021-10-16 13:33:38 +00:00
pub mod impls;
pub mod newtypes;
#[cfg(feature = "full")]
#[rustfmt::skip]
2021-10-16 13:33:38 +00:00
pub mod schema;
pub mod source;
#[cfg(feature = "full")]
2021-10-16 13:33:38 +00:00
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)]
#[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))]
pub enum SortType {
Active,
Hot,
New,
Old,
TopDay,
TopWeek,
TopMonth,
TopYear,
TopAll,
MostComments,
NewComments,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
pub enum CommentSortType {
Hot,
Top,
New,
Old,
}
#[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::ListingTypeEnum"
)]
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
#[cfg_attr(feature = "full", ts(export))]
pub enum ListingType {
All,
Local,
Subscribed,
}
#[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::RegistrationModeEnum"
)]
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
#[cfg_attr(feature = "full", ts(export))]
pub enum RegistrationMode {
Closed,
RequireApplication,
Open,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
#[cfg_attr(feature = "full", derive(TS))]
#[cfg_attr(feature = "full", ts(export))]
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))]
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))]
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))]
pub enum PostFeatureType {
#[default]
Local,
Community,
}