]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
Fixing hot_ranks and scores to append a published sort. (#3618)
[lemmy.git] / crates / db_views / src / structs.rs
1 use lemmy_db_schema::{
2   aggregates::structs::{CommentAggregates, PersonAggregates, PostAggregates, SiteAggregates},
3   source::{
4     comment::Comment,
5     comment_report::CommentReport,
6     community::Community,
7     custom_emoji::CustomEmoji,
8     custom_emoji_keyword::CustomEmojiKeyword,
9     local_site::LocalSite,
10     local_site_rate_limit::LocalSiteRateLimit,
11     local_user::LocalUser,
12     person::Person,
13     post::Post,
14     post_report::PostReport,
15     private_message::PrivateMessage,
16     private_message_report::PrivateMessageReport,
17     registration_application::RegistrationApplication,
18     site::Site,
19   },
20   SubscribedType,
21 };
22 use serde::{Deserialize, Serialize};
23 use serde_with::skip_serializing_none;
24 #[cfg(feature = "full")]
25 use ts_rs::TS;
26
27 #[skip_serializing_none]
28 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
29 #[cfg_attr(feature = "full", derive(TS))]
30 #[cfg_attr(feature = "full", ts(export))]
31 /// A comment report view.
32 pub struct CommentReportView {
33   pub comment_report: CommentReport,
34   pub comment: Comment,
35   pub post: Post,
36   pub community: Community,
37   pub creator: Person,
38   pub comment_creator: Person,
39   pub counts: CommentAggregates,
40   pub creator_banned_from_community: bool,
41   pub my_vote: Option<i16>,
42   pub resolver: Option<Person>,
43 }
44
45 #[skip_serializing_none]
46 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
47 #[cfg_attr(feature = "full", derive(TS))]
48 #[cfg_attr(feature = "full", ts(export))]
49 /// A comment view.
50 pub struct CommentView {
51   pub comment: Comment,
52   pub creator: Person,
53   pub post: Post,
54   pub community: Community,
55   pub counts: CommentAggregates,
56   pub creator_banned_from_community: bool,
57   pub subscribed: SubscribedType,
58   pub saved: bool,
59   pub creator_blocked: bool,
60   pub my_vote: Option<i16>,
61 }
62
63 #[derive(Debug, Serialize, Deserialize, Clone)]
64 #[cfg_attr(feature = "full", derive(TS))]
65 #[cfg_attr(feature = "full", ts(export))]
66 /// A local user view.
67 pub struct LocalUserView {
68   pub local_user: LocalUser,
69   pub person: Person,
70   pub counts: PersonAggregates,
71 }
72
73 #[skip_serializing_none]
74 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
75 #[cfg_attr(feature = "full", derive(TS))]
76 #[cfg_attr(feature = "full", ts(export))]
77 /// A post report view.
78 pub struct PostReportView {
79   pub post_report: PostReport,
80   pub post: Post,
81   pub community: Community,
82   pub creator: Person,
83   pub post_creator: Person,
84   pub creator_banned_from_community: bool,
85   pub my_vote: Option<i16>,
86   pub counts: PostAggregates,
87   pub resolver: Option<Person>,
88 }
89
90 #[skip_serializing_none]
91 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
92 #[cfg_attr(feature = "full", derive(TS))]
93 #[cfg_attr(feature = "full", ts(export))]
94 /// A post view.
95 pub struct PostView {
96   pub post: Post,
97   pub creator: Person,
98   pub community: Community,
99   pub creator_banned_from_community: bool,
100   pub counts: PostAggregates,
101   pub subscribed: SubscribedType,
102   pub saved: bool,
103   pub read: bool,
104   pub creator_blocked: bool,
105   pub my_vote: Option<i16>,
106   pub unread_comments: i64,
107 }
108
109 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
110 #[cfg_attr(feature = "full", derive(TS))]
111 #[cfg_attr(feature = "full", ts(export))]
112 /// A private message view.
113 pub struct PrivateMessageView {
114   pub private_message: PrivateMessage,
115   pub creator: Person,
116   pub recipient: Person,
117 }
118
119 #[skip_serializing_none]
120 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
121 #[cfg_attr(feature = "full", derive(TS))]
122 #[cfg_attr(feature = "full", ts(export))]
123 /// A private message report view.
124 pub struct PrivateMessageReportView {
125   pub private_message_report: PrivateMessageReport,
126   pub private_message: PrivateMessage,
127   pub private_message_creator: Person,
128   pub creator: Person,
129   pub resolver: Option<Person>,
130 }
131
132 #[skip_serializing_none]
133 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
134 #[cfg_attr(feature = "full", derive(TS))]
135 #[cfg_attr(feature = "full", ts(export))]
136 /// A registration application view.
137 pub struct RegistrationApplicationView {
138   pub registration_application: RegistrationApplication,
139   pub creator_local_user: LocalUser,
140   pub creator: Person,
141   pub admin: Option<Person>,
142 }
143
144 #[derive(Debug, Serialize, Deserialize, Clone)]
145 #[cfg_attr(feature = "full", derive(TS))]
146 #[cfg_attr(feature = "full", ts(export))]
147 /// A site view.
148 pub struct SiteView {
149   pub site: Site,
150   pub local_site: LocalSite,
151   pub local_site_rate_limit: LocalSiteRateLimit,
152   pub counts: SiteAggregates,
153 }
154
155 #[derive(Debug, Serialize, Deserialize, Clone)]
156 #[cfg_attr(feature = "full", derive(TS))]
157 #[cfg_attr(feature = "full", ts(export))]
158 /// A custom emoji view.
159 pub struct CustomEmojiView {
160   pub custom_emoji: CustomEmoji,
161   pub keywords: Vec<CustomEmojiKeyword>,
162 }