]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/community.rs
Enable lto, strip symbols via cargo.toml (#2512)
[lemmy.git] / crates / db_schema / src / source / community.rs
1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use serde::{Deserialize, Serialize};
3
4 #[cfg(feature = "full")]
5 use crate::schema::{community, community_follower, community_moderator, community_person_ban};
6
7 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = community))]
10 pub struct Community {
11   pub id: CommunityId,
12   pub name: String,
13   pub title: String,
14   pub description: Option<String>,
15   pub removed: bool,
16   pub published: chrono::NaiveDateTime,
17   pub updated: Option<chrono::NaiveDateTime>,
18   pub deleted: bool,
19   pub nsfw: bool,
20   pub actor_id: DbUrl,
21   pub local: bool,
22   pub private_key: Option<String>,
23   pub public_key: String,
24   pub last_refreshed_at: chrono::NaiveDateTime,
25   pub icon: Option<DbUrl>,
26   pub banner: Option<DbUrl>,
27   pub followers_url: DbUrl,
28   pub inbox_url: DbUrl,
29   pub shared_inbox_url: Option<DbUrl>,
30   pub hidden: bool,
31   pub posting_restricted_to_mods: bool,
32 }
33
34 /// A safe representation of community, without the sensitive info
35 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
37 #[cfg_attr(feature = "full", diesel(table_name = community))]
38 pub struct CommunitySafe {
39   pub id: CommunityId,
40   pub name: String,
41   pub title: String,
42   pub description: Option<String>,
43   pub removed: bool,
44   pub published: chrono::NaiveDateTime,
45   pub updated: Option<chrono::NaiveDateTime>,
46   pub deleted: bool,
47   pub nsfw: bool,
48   pub actor_id: DbUrl,
49   pub local: bool,
50   pub icon: Option<DbUrl>,
51   pub banner: Option<DbUrl>,
52   pub hidden: bool,
53   pub posting_restricted_to_mods: bool,
54 }
55
56 #[derive(Debug, Default)]
57 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
58 #[cfg_attr(feature = "full", diesel(table_name = community))]
59 pub struct CommunityForm {
60   pub name: String,
61   pub title: String,
62   pub description: Option<Option<String>>,
63   pub removed: Option<bool>,
64   pub published: Option<chrono::NaiveDateTime>,
65   pub updated: Option<chrono::NaiveDateTime>,
66   pub deleted: Option<bool>,
67   pub nsfw: Option<bool>,
68   pub actor_id: Option<DbUrl>,
69   pub local: Option<bool>,
70   pub private_key: Option<Option<String>>,
71   pub public_key: Option<String>,
72   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
73   pub icon: Option<Option<DbUrl>>,
74   pub banner: Option<Option<DbUrl>>,
75   pub followers_url: Option<DbUrl>,
76   pub inbox_url: Option<DbUrl>,
77   pub shared_inbox_url: Option<Option<DbUrl>>,
78   pub hidden: Option<bool>,
79   pub posting_restricted_to_mods: Option<bool>,
80 }
81
82 #[derive(PartialEq, Eq, Debug)]
83 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
84 #[cfg_attr(
85   feature = "full",
86   diesel(belongs_to(crate::source::community::Community))
87 )]
88 #[cfg_attr(feature = "full", diesel(table_name = community_moderator))]
89 pub struct CommunityModerator {
90   pub id: i32,
91   pub community_id: CommunityId,
92   pub person_id: PersonId,
93   pub published: chrono::NaiveDateTime,
94 }
95
96 #[derive(Clone)]
97 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
98 #[cfg_attr(feature = "full", diesel(table_name = community_moderator))]
99 pub struct CommunityModeratorForm {
100   pub community_id: CommunityId,
101   pub person_id: PersonId,
102 }
103
104 #[derive(PartialEq, Eq, Debug)]
105 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
106 #[cfg_attr(
107   feature = "full",
108   diesel(belongs_to(crate::source::community::Community))
109 )]
110 #[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
111 pub struct CommunityPersonBan {
112   pub id: i32,
113   pub community_id: CommunityId,
114   pub person_id: PersonId,
115   pub published: chrono::NaiveDateTime,
116   pub expires: Option<chrono::NaiveDateTime>,
117 }
118
119 #[derive(Clone)]
120 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
121 #[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
122 pub struct CommunityPersonBanForm {
123   pub community_id: CommunityId,
124   pub person_id: PersonId,
125   pub expires: Option<Option<chrono::NaiveDateTime>>,
126 }
127
128 #[derive(PartialEq, Eq, Debug)]
129 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
130 #[cfg_attr(
131   feature = "full",
132   diesel(belongs_to(crate::source::community::Community))
133 )]
134 #[cfg_attr(feature = "full", diesel(table_name = community_follower))]
135 pub struct CommunityFollower {
136   pub id: i32,
137   pub community_id: CommunityId,
138   pub person_id: PersonId,
139   pub published: chrono::NaiveDateTime,
140   pub pending: Option<bool>,
141 }
142
143 #[derive(Clone)]
144 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
145 #[cfg_attr(feature = "full", diesel(table_name = community_follower))]
146 pub struct CommunityFollowerForm {
147   pub community_id: CommunityId,
148   pub person_id: PersonId,
149   pub pending: bool,
150 }