]> Untitled Git - lemmy.git/blob - crates/db_views/src/structs.rs
Tag posts and comments with language (fixes #440) (#2269)
[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, PersonSafeAlias1, PersonSafeAlias2},
10     post::Post,
11     post_report::PostReport,
12     private_message::PrivateMessage,
13     registration_application::RegistrationApplication,
14     site::Site,
15   },
16   SubscribedType,
17 };
18 use serde::{Deserialize, Serialize};
19
20 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
21 pub struct CommentReportView {
22   pub comment_report: CommentReport,
23   pub comment: Comment,
24   pub post: Post,
25   pub community: CommunitySafe,
26   pub creator: PersonSafe,
27   pub comment_creator: PersonSafeAlias1,
28   pub counts: CommentAggregates,
29   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
30   pub my_vote: Option<i16>,                // Left join to CommentLike
31   pub resolver: Option<PersonSafeAlias2>,
32 }
33
34 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
35 pub struct CommentView {
36   pub comment: Comment,
37   pub creator: PersonSafe,
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   pub language: Language,
88 }
89
90 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
91 pub struct PrivateMessageView {
92   pub private_message: PrivateMessage,
93   pub creator: PersonSafe,
94   pub recipient: PersonSafeAlias1,
95 }
96
97 #[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
98 pub struct RegistrationApplicationView {
99   pub registration_application: RegistrationApplication,
100   pub creator_local_user: LocalUserSettings,
101   pub creator: PersonSafe,
102   pub admin: Option<PersonSafeAlias1>,
103 }
104
105 #[derive(Debug, Serialize, Deserialize, Clone)]
106 pub struct SiteView {
107   pub site: Site,
108   pub counts: SiteAggregates,
109 }
110
111 #[derive(Debug, Serialize, Deserialize, Clone)]
112 pub struct LocalUserDiscussionLanguageView {
113   pub local_user: LocalUserSettings,
114   pub language: Language,
115 }