]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
Get rid of Safe Views, use serde_skip (#2767)
[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     local_site::LocalSite,
8     local_site_rate_limit::LocalSiteRateLimit,
9     local_user::LocalUser,
10     person::Person,
11     post::Post,
12     post_report::PostReport,
13     private_message::PrivateMessage,
14     private_message_report::PrivateMessageReport,
15     registration_application::RegistrationApplication,
16     site::Site,
17   },
18   SubscribedType,
19 };
20 use serde::{Deserialize, Serialize};
21
22 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
23 pub struct CommentReportView {
24   pub comment_report: CommentReport,
25   pub comment: Comment,
26   pub post: Post,
27   pub community: Community,
28   pub creator: Person,
29   pub comment_creator: Person,
30   pub counts: CommentAggregates,
31   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
32   pub my_vote: Option<i16>,                // Left join to CommentLike
33   pub resolver: Option<Person>,
34 }
35
36 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
37 pub struct CommentView {
38   pub comment: Comment,
39   pub creator: Person,
40   pub post: Post,
41   pub community: Community,
42   pub counts: CommentAggregates,
43   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
44   pub subscribed: SubscribedType,          // Left join to CommunityFollower
45   pub saved: bool,                         // Left join to CommentSaved
46   pub creator_blocked: bool,               // Left join to PersonBlock
47   pub my_vote: Option<i16>,                // Left join to CommentLike
48 }
49
50 #[derive(Debug, Serialize, Deserialize, Clone)]
51 pub struct LocalUserView {
52   pub local_user: LocalUser,
53   pub person: Person,
54   pub counts: PersonAggregates,
55 }
56
57 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
58 pub struct PostReportView {
59   pub post_report: PostReport,
60   pub post: Post,
61   pub community: Community,
62   pub creator: Person,
63   pub post_creator: Person,
64   pub creator_banned_from_community: bool,
65   pub my_vote: Option<i16>,
66   pub counts: PostAggregates,
67   pub resolver: Option<Person>,
68 }
69
70 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
71 pub struct PostView {
72   pub post: Post,
73   pub creator: Person,
74   pub community: Community,
75   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
76   pub counts: PostAggregates,
77   pub subscribed: SubscribedType, // Left join to CommunityFollower
78   pub saved: bool,                // Left join to PostSaved
79   pub read: bool,                 // Left join to PostRead
80   pub creator_blocked: bool,      // Left join to PersonBlock
81   pub my_vote: Option<i16>,       // Left join to PostLike
82   pub unread_comments: i64,       // Left join to PersonPostAggregates
83 }
84
85 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
86 pub struct PrivateMessageView {
87   pub private_message: PrivateMessage,
88   pub creator: Person,
89   pub recipient: Person,
90 }
91
92 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
93 pub struct PrivateMessageReportView {
94   pub private_message_report: PrivateMessageReport,
95   pub private_message: PrivateMessage,
96   pub private_message_creator: Person,
97   pub creator: Person,
98   pub resolver: Option<Person>,
99 }
100
101 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
102 pub struct RegistrationApplicationView {
103   pub registration_application: RegistrationApplication,
104   pub creator_local_user: LocalUser,
105   pub creator: Person,
106   pub admin: Option<Person>,
107 }
108
109 #[derive(Debug, Serialize, Deserialize, Clone)]
110 pub struct SiteView {
111   pub site: Site,
112   pub local_site: LocalSite,
113   pub local_site_rate_limit: LocalSiteRateLimit,
114   pub counts: SiteAggregates,
115 }