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