]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
Fixing missing forms, incorrect user discussion_languages (#2580)
[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::CommunitySafe,
7     local_site::LocalSite,
8     local_site_rate_limit::LocalSiteRateLimit,
9     local_user::{LocalUser, LocalUserSettings},
10     person::{Person, PersonSafe},
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: CommunitySafe,
28   pub creator: PersonSafe,
29   pub comment_creator: PersonSafe,
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<PersonSafe>,
34 }
35
36 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
37 pub struct CommentView {
38   pub comment: Comment,
39   pub creator: PersonSafe,
40   pub post: Post,
41   pub community: CommunitySafe,
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, Serialize, Deserialize, Clone)]
58 pub struct LocalUserSettingsView {
59   pub local_user: LocalUserSettings,
60   pub person: PersonSafe,
61   pub counts: PersonAggregates,
62 }
63
64 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
65 pub struct PostReportView {
66   pub post_report: PostReport,
67   pub post: Post,
68   pub community: CommunitySafe,
69   pub creator: PersonSafe,
70   pub post_creator: PersonSafe,
71   pub creator_banned_from_community: bool,
72   pub my_vote: Option<i16>,
73   pub counts: PostAggregates,
74   pub resolver: Option<PersonSafe>,
75 }
76
77 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
78 pub struct PostView {
79   pub post: Post,
80   pub creator: PersonSafe,
81   pub community: CommunitySafe,
82   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
83   pub counts: PostAggregates,
84   pub subscribed: SubscribedType, // Left join to CommunityFollower
85   pub saved: bool,                // Left join to PostSaved
86   pub read: bool,                 // Left join to PostRead
87   pub creator_blocked: bool,      // Left join to PersonBlock
88   pub my_vote: Option<i16>,       // Left join to PostLike
89   pub unread_comments: i64,       // Left join to PersonPostAggregates
90 }
91
92 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
93 pub struct PrivateMessageView {
94   pub private_message: PrivateMessage,
95   pub creator: PersonSafe,
96   pub recipient: PersonSafe,
97 }
98
99 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
100 pub struct PrivateMessageReportView {
101   pub private_message_report: PrivateMessageReport,
102   pub private_message: PrivateMessage,
103   pub private_message_creator: PersonSafe,
104   pub creator: PersonSafe,
105   pub resolver: Option<PersonSafe>,
106 }
107
108 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
109 pub struct RegistrationApplicationView {
110   pub registration_application: RegistrationApplication,
111   pub creator_local_user: LocalUserSettings,
112   pub creator: PersonSafe,
113   pub admin: Option<PersonSafe>,
114 }
115
116 #[derive(Debug, Serialize, Deserialize, Clone)]
117 pub struct SiteView {
118   pub site: Site,
119   pub local_site: LocalSite,
120   pub local_site_rate_limit: LocalSiteRateLimit,
121   pub counts: SiteAggregates,
122 }