1#[cfg(feature = "full")]
2use diesel::Queryable;
3use lemmy_db_schema::{
4 aggregates::structs::{CommentAggregates, PersonAggregates, PostAggregates, SiteAggregates},
5 source::{
6 comment::Comment,
7 comment_report::CommentReport,
8 community::Community,
9 custom_emoji::CustomEmoji,
10 custom_emoji_keyword::CustomEmojiKeyword,
11 images::{ImageDetails, LocalImage},
12 local_site::LocalSite,
13 local_site_rate_limit::LocalSiteRateLimit,
14 local_user::LocalUser,
15 local_user_vote_display_mode::LocalUserVoteDisplayMode,
16 person::Person,
17 post::Post,
18 post_report::PostReport,
19 private_message::PrivateMessage,
20 private_message_report::PrivateMessageReport,
21 registration_application::RegistrationApplication,
22 site::Site,
23 },
24 SubscribedType,
25};
26use serde::{Deserialize, Serialize};
27use serde_with::skip_serializing_none;
28#[cfg(feature = "full")]
29use ts_rs::TS;
30
31#[skip_serializing_none]
32#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
33#[cfg_attr(feature = "full", derive(TS, Queryable))]
34#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
35#[cfg_attr(feature = "full", ts(export))]
36pub struct CommentReportView {
38 pub comment_report: CommentReport,
39 pub comment: Comment,
40 pub post: Post,
41 pub community: Community,
42 pub creator: Person,
43 pub comment_creator: Person,
44 pub counts: CommentAggregates,
45 pub creator_banned_from_community: bool,
46 pub creator_is_moderator: bool,
47 pub creator_is_admin: bool,
48 pub creator_blocked: bool,
49 pub subscribed: SubscribedType,
50 pub saved: bool,
51 pub my_vote: Option<i16>,
52 pub resolver: Option<Person>,
53}
54
55#[skip_serializing_none]
56#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
57#[cfg_attr(feature = "full", derive(TS, Queryable))]
58#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
59#[cfg_attr(feature = "full", ts(export))]
60pub struct CommentView {
62 pub comment: Comment,
63 pub creator: Person,
64 pub post: Post,
65 pub community: Community,
66 pub counts: CommentAggregates,
67 pub creator_banned_from_community: bool,
68 pub banned_from_community: bool,
69 pub creator_is_moderator: bool,
70 pub creator_is_admin: bool,
71 pub subscribed: SubscribedType,
72 pub saved: bool,
73 pub creator_blocked: bool,
74 pub my_vote: Option<i16>,
75}
76
77#[derive(Debug, Serialize, Deserialize, Clone)]
78#[cfg_attr(feature = "full", derive(TS, Queryable))]
79#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
80#[cfg_attr(feature = "full", ts(export))]
81pub struct LocalUserView {
83 pub local_user: LocalUser,
84 pub local_user_vote_display_mode: LocalUserVoteDisplayMode,
85 pub person: Person,
86 pub counts: PersonAggregates,
87}
88
89#[skip_serializing_none]
90#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
91#[cfg_attr(feature = "full", derive(TS, Queryable))]
92#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
93#[cfg_attr(feature = "full", ts(export))]
94pub struct PostReportView {
96 pub post_report: PostReport,
97 pub post: Post,
98 pub community: Community,
99 pub creator: Person,
100 pub post_creator: Person,
101 pub creator_banned_from_community: bool,
102 pub creator_is_moderator: bool,
103 pub creator_is_admin: bool,
104 pub subscribed: SubscribedType,
105 pub saved: bool,
106 pub read: bool,
107 pub hidden: bool,
108 pub creator_blocked: bool,
109 pub my_vote: Option<i16>,
110 pub unread_comments: i64,
111 pub counts: PostAggregates,
112 pub resolver: Option<Person>,
113}
114
115#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
120#[cfg_attr(feature = "full", derive(ts_rs::TS))]
121#[cfg_attr(feature = "full", ts(export))]
122pub struct PaginationCursor(pub String);
123
124#[skip_serializing_none]
125#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
126#[cfg_attr(feature = "full", derive(TS, Queryable))]
127#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
128#[cfg_attr(feature = "full", ts(export))]
129pub struct PostView {
131 pub post: Post,
132 pub creator: Person,
133 pub community: Community,
134 pub image_details: Option<ImageDetails>,
135 pub creator_banned_from_community: bool,
136 pub banned_from_community: bool,
137 pub creator_is_moderator: bool,
138 pub creator_is_admin: bool,
139 pub counts: PostAggregates,
140 pub subscribed: SubscribedType,
141 pub saved: bool,
142 pub read: bool,
143 pub hidden: bool,
144 pub creator_blocked: bool,
145 pub my_vote: Option<i16>,
146 pub unread_comments: i64,
147}
148
149#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
150#[cfg_attr(feature = "full", derive(TS, Queryable))]
151#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
152#[cfg_attr(feature = "full", ts(export))]
153pub struct PrivateMessageView {
155 pub private_message: PrivateMessage,
156 pub creator: Person,
157 pub recipient: Person,
158}
159
160#[skip_serializing_none]
161#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
162#[cfg_attr(feature = "full", derive(TS, Queryable))]
163#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
164#[cfg_attr(feature = "full", ts(export))]
165pub struct PrivateMessageReportView {
167 pub private_message_report: PrivateMessageReport,
168 pub private_message: PrivateMessage,
169 pub private_message_creator: Person,
170 pub creator: Person,
171 pub resolver: Option<Person>,
172}
173
174#[skip_serializing_none]
175#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
176#[cfg_attr(feature = "full", derive(TS, Queryable))]
177#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
178#[cfg_attr(feature = "full", ts(export))]
179pub struct RegistrationApplicationView {
181 pub registration_application: RegistrationApplication,
182 pub creator_local_user: LocalUser,
183 pub creator: Person,
184 pub admin: Option<Person>,
185}
186
187#[derive(Debug, Serialize, Deserialize, Clone)]
188#[cfg_attr(feature = "full", derive(TS, Queryable))]
189#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
190#[cfg_attr(feature = "full", ts(export))]
191pub struct SiteView {
193 pub site: Site,
194 pub local_site: LocalSite,
195 pub local_site_rate_limit: LocalSiteRateLimit,
196 pub counts: SiteAggregates,
197}
198
199#[derive(Debug, Serialize, Deserialize, Clone)]
200#[cfg_attr(feature = "full", derive(TS, Queryable))]
201#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
202#[cfg_attr(feature = "full", ts(export))]
203pub struct CustomEmojiView {
205 pub custom_emoji: CustomEmoji,
206 pub keywords: Vec<CustomEmojiKeyword>,
207}
208
209#[skip_serializing_none]
210#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
211#[cfg_attr(feature = "full", derive(TS, Queryable))]
212#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
213#[cfg_attr(feature = "full", ts(export))]
214pub struct VoteView {
216 pub creator: Person,
217 pub creator_banned_from_community: bool,
218 pub score: i16,
219}
220
221#[skip_serializing_none]
222#[derive(Debug, Serialize, Deserialize, Clone)]
223#[cfg_attr(feature = "full", derive(TS, Queryable))]
224#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
225#[cfg_attr(feature = "full", ts(export))]
226pub struct LocalImageView {
228 pub local_image: LocalImage,
229 pub person: Person,
230}