]> Untitled Git - lemmy.git/blob - crates/db_schema/src/lib.rs
04ec4e7dab04a40a9009d0ff1d0d2147a2d69bd3
[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 }
67
68 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
69 #[cfg_attr(feature = "full", derive(TS))]
70 #[cfg_attr(feature = "full", ts(export))]
71 /// The comment sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
72 pub enum CommentSortType {
73   Hot,
74   Top,
75   New,
76   Old,
77 }
78
79 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
80 #[cfg_attr(feature = "full", derive(DbEnum, TS))]
81 #[cfg_attr(
82   feature = "full",
83   ExistingTypePath = "crate::schema::sql_types::ListingTypeEnum"
84 )]
85 #[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
86 #[cfg_attr(feature = "full", ts(export))]
87 /// A listing type for post and comment list fetches.
88 pub enum ListingType {
89   /// Content from your own site, as well as all connected / federated sites.
90   All,
91   /// Content from your site only.
92   Local,
93   /// Content only from communities you've subscribed to.
94   Subscribed,
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::RegistrationModeEnum"
102 )]
103 #[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
104 #[cfg_attr(feature = "full", ts(export))]
105 /// The registration mode for your site. Determines what happens after a user signs up.
106 pub enum RegistrationMode {
107   /// Closed to public.
108   Closed,
109   /// Open, but pending approval of a registration application.
110   RequireApplication,
111   /// Open to all.
112   Open,
113 }
114
115 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
116 #[cfg_attr(feature = "full", derive(TS))]
117 #[cfg_attr(feature = "full", ts(export))]
118 /// The type of content returned from a search.
119 pub enum SearchType {
120   All,
121   Comments,
122   Posts,
123   Communities,
124   Users,
125   Url,
126 }
127
128 #[derive(EnumString, Display, Debug, PartialEq, Eq, Serialize, Deserialize, Clone, Copy)]
129 #[cfg_attr(feature = "full", derive(TS))]
130 #[cfg_attr(feature = "full", ts(export))]
131 /// A type / status for a community subscribe.
132 pub enum SubscribedType {
133   Subscribed,
134   NotSubscribed,
135   Pending,
136 }
137
138 #[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
139 #[cfg_attr(feature = "full", derive(TS))]
140 #[cfg_attr(feature = "full", ts(export))]
141 /// A list of possible types for the various modlog actions.
142 pub enum ModlogActionType {
143   All,
144   ModRemovePost,
145   ModLockPost,
146   ModFeaturePost,
147   ModRemoveComment,
148   ModRemoveCommunity,
149   ModBanFromCommunity,
150   ModAddCommunity,
151   ModTransferCommunity,
152   ModAdd,
153   ModBan,
154   ModHideCommunity,
155   AdminPurgePerson,
156   AdminPurgeCommunity,
157   AdminPurgePost,
158   AdminPurgeComment,
159 }
160
161 #[derive(
162   EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, Default, PartialEq, Eq,
163 )]
164 #[cfg_attr(feature = "full", derive(TS))]
165 #[cfg_attr(feature = "full", ts(export))]
166 /// The feature type for a post.
167 pub enum PostFeatureType {
168   #[default]
169   /// Features to the top of your site.
170   Local,
171   /// Features to the top of the community.
172   Community,
173 }