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