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