]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
b92bb271481a086285a7f36e120d8985f1b63927
[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 recipient: Option<PersonSafeAlias1>, // Left joins to comment and person
38   pub post: Post,
39   pub community: CommunitySafe,
40   pub counts: CommentAggregates,
41   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
42   pub subscribed: SubscribedType,          // Left join to CommunityFollower
43   pub saved: bool,                         // Left join to CommentSaved
44   pub creator_blocked: bool,               // Left join to PersonBlock
45   pub my_vote: Option<i16>,                // Left join to CommentLike
46 }
47
48 #[derive(Debug, Serialize, Deserialize, Clone)]
49 pub struct LocalUserView {
50   pub local_user: LocalUser,
51   pub person: Person,
52   pub counts: PersonAggregates,
53 }
54
55 #[derive(Debug, Serialize, Deserialize, Clone)]
56 pub struct LocalUserSettingsView {
57   pub local_user: LocalUserSettings,
58   pub person: PersonSafe,
59   pub counts: PersonAggregates,
60 }
61
62 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
63 pub struct PostReportView {
64   pub post_report: PostReport,
65   pub post: Post,
66   pub community: CommunitySafe,
67   pub creator: PersonSafe,
68   pub post_creator: PersonSafeAlias1,
69   pub creator_banned_from_community: bool,
70   pub my_vote: Option<i16>,
71   pub counts: PostAggregates,
72   pub resolver: Option<PersonSafeAlias2>,
73 }
74
75 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
76 pub struct PostView {
77   pub post: Post,
78   pub creator: PersonSafe,
79   pub community: CommunitySafe,
80   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
81   pub counts: PostAggregates,
82   pub subscribed: SubscribedType, // Left join to CommunityFollower
83   pub saved: bool,                // Left join to PostSaved
84   pub read: bool,                 // Left join to PostRead
85   pub creator_blocked: bool,      // Left join to PersonBlock
86   pub my_vote: Option<i16>,       // Left join to PostLike
87 }
88
89 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
90 pub struct PrivateMessageView {
91   pub private_message: PrivateMessage,
92   pub creator: PersonSafe,
93   pub recipient: PersonSafeAlias1,
94 }
95
96 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
97 pub struct RegistrationApplicationView {
98   pub registration_application: RegistrationApplication,
99   pub creator_local_user: LocalUserSettings,
100   pub creator: PersonSafe,
101   pub admin: Option<PersonSafeAlias1>,
102 }
103
104 #[derive(Debug, Serialize, Deserialize, Clone)]
105 pub struct SiteView {
106   pub site: Site,
107   pub counts: SiteAggregates,
108 }