2022-10-27 09:24:07 +00:00
|
|
|
#![recursion_limit = "256"]
|
|
|
|
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
#[macro_use]
|
2020-12-18 16:17:21 +00:00
|
|
|
extern crate diesel;
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
2021-03-18 20:25:21 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_derive_newtype;
|
2023-04-17 19:19:51 +00:00
|
|
|
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_derive_enum;
|
|
|
|
|
2021-10-16 13:33:38 +00:00
|
|
|
// this is used in tests
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
2021-10-16 13:33:38 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate diesel_migrations;
|
2021-03-18 20:25:21 +00:00
|
|
|
|
2022-11-17 15:23:01 +00:00
|
|
|
#[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;
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
2021-10-16 13:33:38 +00:00
|
|
|
pub mod impls;
|
|
|
|
pub mod newtypes;
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
2023-04-17 19:19:51 +00:00
|
|
|
#[rustfmt::skip]
|
2023-06-26 09:18:29 +00:00
|
|
|
#[allow(clippy::wildcard_imports)]
|
2021-10-16 13:33:38 +00:00
|
|
|
pub mod schema;
|
2023-07-28 08:36:50 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
pub mod aliases {
|
|
|
|
use crate::schema::person;
|
|
|
|
diesel::alias!(person as person1: Person1, person as person2: Person2);
|
|
|
|
}
|
2021-10-16 13:33:38 +00:00
|
|
|
pub mod source;
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
2021-10-16 13:33:38 +00:00
|
|
|
pub mod traits;
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
pub mod utils;
|
2022-05-06 20:55:07 +00:00
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use strum_macros::{Display, EnumString};
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2022-05-06 20:55:07 +00:00
|
|
|
|
2023-04-17 19:19:51 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(DbEnum, TS))]
|
2023-04-17 19:19:51 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
ExistingTypePath = "crate::schema::sql_types::SortTypeEnum"
|
|
|
|
)]
|
|
|
|
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The post sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
|
2022-05-06 20:55:07 +00:00
|
|
|
pub enum SortType {
|
|
|
|
Active,
|
|
|
|
Hot,
|
|
|
|
New,
|
2022-07-30 03:55:59 +00:00
|
|
|
Old,
|
2022-05-06 20:55:07 +00:00
|
|
|
TopDay,
|
|
|
|
TopWeek,
|
|
|
|
TopMonth,
|
|
|
|
TopYear,
|
|
|
|
TopAll,
|
|
|
|
MostComments,
|
|
|
|
NewComments,
|
2023-06-20 14:05:43 +00:00
|
|
|
TopHour,
|
|
|
|
TopSixHour,
|
|
|
|
TopTwelveHour,
|
2023-06-26 19:03:35 +00:00
|
|
|
TopThreeMonths,
|
|
|
|
TopSixMonths,
|
|
|
|
TopNineMonths,
|
2023-07-26 17:07:05 +00:00
|
|
|
Controversial,
|
2022-05-06 20:55:07 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 03:55:59 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The comment sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
|
2022-07-30 03:55:59 +00:00
|
|
|
pub enum CommentSortType {
|
|
|
|
Hot,
|
|
|
|
Top,
|
|
|
|
New,
|
|
|
|
Old,
|
2023-07-26 17:07:05 +00:00
|
|
|
Controversial,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
|
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
|
|
|
/// The person sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
|
|
|
|
pub enum PersonSortType {
|
|
|
|
New,
|
|
|
|
Old,
|
|
|
|
MostComments,
|
|
|
|
CommentScore,
|
|
|
|
PostScore,
|
|
|
|
PostCount,
|
2022-07-30 03:55:59 +00:00
|
|
|
}
|
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(DbEnum, TS))]
|
2023-04-17 19:19:51 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
ExistingTypePath = "crate::schema::sql_types::ListingTypeEnum"
|
|
|
|
)]
|
|
|
|
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A listing type for post and comment list fetches.
|
2022-05-06 20:55:07 +00:00
|
|
|
pub enum ListingType {
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Content from your own site, as well as all connected / federated sites.
|
2022-05-06 20:55:07 +00:00
|
|
|
All,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Content from your site only.
|
2022-05-06 20:55:07 +00:00
|
|
|
Local,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Content only from communities you've subscribed to.
|
2022-05-06 20:55:07 +00:00
|
|
|
Subscribed,
|
|
|
|
}
|
|
|
|
|
2023-04-17 19:19:51 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(DbEnum, TS))]
|
2023-04-17 19:19:51 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
ExistingTypePath = "crate::schema::sql_types::RegistrationModeEnum"
|
|
|
|
)]
|
|
|
|
#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The registration mode for your site. Determines what happens after a user signs up.
|
2023-04-17 19:19:51 +00:00
|
|
|
pub enum RegistrationMode {
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Closed to public.
|
2023-04-17 19:19:51 +00:00
|
|
|
Closed,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Open, but pending approval of a registration application.
|
2023-04-17 19:19:51 +00:00
|
|
|
RequireApplication,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Open to all.
|
2023-04-17 19:19:51 +00:00
|
|
|
Open,
|
|
|
|
}
|
|
|
|
|
2022-05-06 20:55:07 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The type of content returned from a search.
|
2022-05-06 20:55:07 +00:00
|
|
|
pub enum SearchType {
|
|
|
|
All,
|
|
|
|
Comments,
|
|
|
|
Posts,
|
|
|
|
Communities,
|
|
|
|
Users,
|
|
|
|
Url,
|
|
|
|
}
|
2022-06-22 12:05:41 +00:00
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A type / status for a community subscribe.
|
2022-06-22 12:05:41 +00:00
|
|
|
pub enum SubscribedType {
|
|
|
|
Subscribed,
|
|
|
|
NotSubscribed,
|
|
|
|
Pending,
|
|
|
|
}
|
2022-08-16 11:52:04 +00:00
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A list of possible types for the various modlog actions.
|
2022-08-16 11:52:04 +00:00
|
|
|
pub enum ModlogActionType {
|
|
|
|
All,
|
|
|
|
ModRemovePost,
|
|
|
|
ModLockPost,
|
2022-12-12 11:17:10 +00:00
|
|
|
ModFeaturePost,
|
2022-08-16 11:52:04 +00:00
|
|
|
ModRemoveComment,
|
|
|
|
ModRemoveCommunity,
|
|
|
|
ModBanFromCommunity,
|
|
|
|
ModAddCommunity,
|
|
|
|
ModTransferCommunity,
|
|
|
|
ModAdd,
|
|
|
|
ModBan,
|
|
|
|
ModHideCommunity,
|
|
|
|
AdminPurgePerson,
|
|
|
|
AdminPurgeCommunity,
|
|
|
|
AdminPurgePost,
|
|
|
|
AdminPurgeComment,
|
|
|
|
}
|
2022-12-12 11:17:10 +00:00
|
|
|
|
|
|
|
#[derive(
|
|
|
|
EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq,
|
|
|
|
)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(TS))]
|
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The feature type for a post.
|
2022-12-12 11:17:10 +00:00
|
|
|
pub enum PostFeatureType {
|
|
|
|
#[default]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Features to the top of your site.
|
2022-12-12 11:17:10 +00:00
|
|
|
Local,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Features to the top of the community.
|
2022-12-12 11:17:10 +00:00
|
|
|
Community,
|
|
|
|
}
|