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