]> Untitled Git - lemmy.git/blob - crates/db_views_actor/src/structs.rs
Diesel 2.0.0 upgrade (#2452)
[lemmy.git] / crates / db_views_actor / src / structs.rs
1 use lemmy_db_schema::{
2   aggregates::structs::{CommentAggregates, CommunityAggregates, PersonAggregates},
3   source::{
4     comment::Comment,
5     comment_reply::CommentReply,
6     community::CommunitySafe,
7     person::PersonSafe,
8     person_mention::PersonMention,
9     post::Post,
10   },
11   SubscribedType,
12 };
13 use serde::{Deserialize, Serialize};
14
15 #[derive(Debug, Serialize, Deserialize, Clone)]
16 pub struct CommunityBlockView {
17   pub person: PersonSafe,
18   pub community: CommunitySafe,
19 }
20
21 #[derive(Debug, Serialize, Deserialize, Clone)]
22 pub struct CommunityFollowerView {
23   pub community: CommunitySafe,
24   pub follower: PersonSafe,
25 }
26
27 #[derive(Debug, Serialize, Deserialize, Clone)]
28 pub struct CommunityModeratorView {
29   pub community: CommunitySafe,
30   pub moderator: PersonSafe,
31 }
32
33 #[derive(Debug, Serialize, Deserialize, Clone)]
34 pub struct CommunityPersonBanView {
35   pub community: CommunitySafe,
36   pub person: PersonSafe,
37 }
38
39 #[derive(Debug, Serialize, Deserialize, Clone)]
40 pub struct CommunityView {
41   pub community: CommunitySafe,
42   pub subscribed: SubscribedType,
43   pub blocked: bool,
44   pub counts: CommunityAggregates,
45 }
46
47 #[derive(Debug, Serialize, Deserialize, Clone)]
48 pub struct PersonBlockView {
49   pub person: PersonSafe,
50   pub target: PersonSafe,
51 }
52
53 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
54 pub struct PersonMentionView {
55   pub person_mention: PersonMention,
56   pub comment: Comment,
57   pub creator: PersonSafe,
58   pub post: Post,
59   pub community: CommunitySafe,
60   pub recipient: PersonSafe,
61   pub counts: CommentAggregates,
62   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
63   pub subscribed: SubscribedType,          // Left join to CommunityFollower
64   pub saved: bool,                         // Left join to CommentSaved
65   pub creator_blocked: bool,               // Left join to PersonBlock
66   pub my_vote: Option<i16>,                // Left join to CommentLike
67 }
68
69 #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
70 pub struct CommentReplyView {
71   pub comment_reply: CommentReply,
72   pub comment: Comment,
73   pub creator: PersonSafe,
74   pub post: Post,
75   pub community: CommunitySafe,
76   pub recipient: PersonSafe,
77   pub counts: CommentAggregates,
78   pub creator_banned_from_community: bool, // Left Join to CommunityPersonBan
79   pub subscribed: SubscribedType,          // Left join to CommunityFollower
80   pub saved: bool,                         // Left join to CommentSaved
81   pub creator_blocked: bool,               // Left join to PersonBlock
82   pub my_vote: Option<i16>,                // Left join to CommentLike
83 }
84
85 #[derive(Debug, Serialize, Deserialize, Clone)]
86 pub struct PersonViewSafe {
87   pub person: PersonSafe,
88   pub counts: PersonAggregates,
89 }