]> Untitled Git - lemmy.git/blob - crates/db_schema/src/lib.rs
e5b86fe1977e076b983ec777e9a24447efbf26ee
[lemmy.git] / crates / db_schema / src / lib.rs
1 #![recursion_limit = "256"]
2
3 #[cfg(feature = "full")]
4 #[macro_use]
5 extern crate diesel;
6 #[cfg(feature = "full")]
7 #[macro_use]
8 extern crate diesel_derive_newtype;
9
10 #[cfg(feature = "full")]
11 #[macro_use]
12 extern crate diesel_derive_enum;
13
14 // this is used in tests
15 #[cfg(feature = "full")]
16 #[macro_use]
17 extern crate diesel_migrations;
18
19 #[cfg(feature = "full")]
20 #[macro_use]
21 extern crate async_trait;
22
23 pub mod aggregates;
24 #[cfg(feature = "full")]
25 pub mod impls;
26 pub mod newtypes;
27 #[cfg(feature = "full")]
28 #[rustfmt::skip]
29 #[allow(clippy::wildcard_imports)]
30 pub mod schema;
31 pub mod source;
32 #[cfg(feature = "full")]
33 pub mod traits;
34 #[cfg(feature = "full")]
35 pub mod utils;
36
37 use serde::{Deserialize, Serialize};
38 use strum_macros::{Display, EnumString};
39 #[cfg(feature = "full")]
40 use ts_rs::TS;
41
42 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
43 #[cfg_attr(feature = "full", derive(DbEnum, TS))]
44 #[cfg_attr(
45   feature = "full",
46   ExistingTypePath = "crate::schema::sql_types::SortTypeEnum"
47 )]
48 #[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
49 #[cfg_attr(feature = "full", ts(export))]
50 /// The post sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
51 pub enum SortType {
52   Active,
53   Hot,
54   New,
55   Old,
56   TopDay,
57   TopWeek,
58   TopMonth,
59   TopYear,
60   TopAll,
61   MostComments,
62   NewComments,
63   TopHour,
64   TopSixHour,
65   TopTwelveHour,
66   TopThreeMonths,
67   TopSixMonths,
68   TopNineMonths,
69   Controversial,
70 }
71
72 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
73 #[cfg_attr(feature = "full", derive(TS))]
74 #[cfg_attr(feature = "full", ts(export))]
75 /// The comment sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
76 pub enum CommentSortType {
77   Hot,
78   Top,
79   New,
80   Old,
81   Controversial,
82 }
83
84 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
85 #[cfg_attr(feature = "full", derive(TS))]
86 #[cfg_attr(feature = "full", ts(export))]
87 /// The person sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
88 pub enum PersonSortType {
89   New,
90   Old,
91   MostComments,
92   CommentScore,
93   PostScore,
94   PostCount,
95 }
96
97 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
98 #[cfg_attr(feature = "full", derive(DbEnum, TS))]
99 #[cfg_attr(
100   feature = "full",
101   ExistingTypePath = "crate::schema::sql_types::ListingTypeEnum"
102 )]
103 #[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
104 #[cfg_attr(feature = "full", ts(export))]
105 /// A listing type for post and comment list fetches.
106 pub enum ListingType {
107   /// Content from your own site, as well as all connected / federated sites.
108   All,
109   /// Content from your site only.
110   Local,
111   /// Content only from communities you've subscribed to.
112   Subscribed,
113 }
114
115 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
116 #[cfg_attr(feature = "full", derive(DbEnum, TS))]
117 #[cfg_attr(
118   feature = "full",
119   ExistingTypePath = "crate::schema::sql_types::RegistrationModeEnum"
120 )]
121 #[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
122 #[cfg_attr(feature = "full", ts(export))]
123 /// The registration mode for your site. Determines what happens after a user signs up.
124 pub enum RegistrationMode {
125   /// Closed to public.
126   Closed,
127   /// Open, but pending approval of a registration application.
128   RequireApplication,
129   /// Open to all.
130   Open,
131 }
132
133 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
134 #[cfg_attr(feature = "full", derive(TS))]
135 #[cfg_attr(feature = "full", ts(export))]
136 /// The type of content returned from a search.
137 pub enum SearchType {
138   All,
139   Comments,
140   Posts,
141   Communities,
142   Users,
143   Url,
144 }
145
146 #[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)]
147 #[cfg_attr(feature = "full", derive(TS))]
148 #[cfg_attr(feature = "full", ts(export))]
149 /// A type / status for a community subscribe.
150 pub enum SubscribedType {
151   Subscribed,
152   NotSubscribed,
153   Pending,
154 }
155
156 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
157 #[cfg_attr(feature = "full", derive(TS))]
158 #[cfg_attr(feature = "full", ts(export))]
159 /// A list of possible types for the various modlog actions.
160 pub enum ModlogActionType {
161   All,
162   ModRemovePost,
163   ModLockPost,
164   ModFeaturePost,
165   ModRemoveComment,
166   ModRemoveCommunity,
167   ModBanFromCommunity,
168   ModAddCommunity,
169   ModTransferCommunity,
170   ModAdd,
171   ModBan,
172   ModHideCommunity,
173   AdminPurgePerson,
174   AdminPurgeCommunity,
175   AdminPurgePost,
176   AdminPurgeComment,
177 }
178
179 #[derive(
180   EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq,
181 )]
182 #[cfg_attr(feature = "full", derive(TS))]
183 #[cfg_attr(feature = "full", ts(export))]
184 /// The feature type for a post.
185 pub enum PostFeatureType {
186   #[default]
187   /// Features to the top of your site.
188   Local,
189   /// Features to the top of the community.
190   Community,
191 }