]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
Showing # of unread comments for posts. Fixes #2134 (#2393)
[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   pub unread_comments: i64,       // Left join to PersonPostAggregates
89 }
90
91 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
92 pub struct PrivateMessageView {
93   pub private_message: PrivateMessage,
94   pub creator: PersonSafe,
95   pub recipient: PersonSafe,
96 }
97
98 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
99 pub struct PrivateMessageReportView {
100   pub private_message_report: PrivateMessageReport,
101   pub private_message: PrivateMessage,
102   pub private_message_creator: PersonSafe,
103   pub creator: PersonSafe,
104   pub resolver: Option<PersonSafe>,
105 }
106
107 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
108 pub struct RegistrationApplicationView {
109   pub registration_application: RegistrationApplication,
110   pub creator_local_user: LocalUserSettings,
111   pub creator: PersonSafe,
112   pub admin: Option<PersonSafe>,
113 }
114
115 #[derive(Debug, Serialize, Deserialize, Clone)]
116 pub struct SiteView {
117   pub site: Site,
118   pub counts: SiteAggregates,
119 }
120
121 #[derive(Debug, Serialize, Deserialize, Clone)]
122 pub struct LocalUserDiscussionLanguageView {
123   pub local_user: LocalUserSettings,
124   pub language: Language,
125 }