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