1 use crate::newtypes::{CommunityId, DbUrl, PersonId};
2 use serde::{Deserialize, Serialize};
4 #[cfg(feature = "full")]
5 use crate::schema::{community, community_follower, community_moderator, community_person_ban};
7 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", table_name = "community")]
10 pub struct Community {
14 pub description: Option<String>,
16 pub published: chrono::NaiveDateTime,
17 pub updated: Option<chrono::NaiveDateTime>,
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,
29 pub shared_inbox_url: Option<DbUrl>,
31 pub posting_restricted_to_mods: bool,
34 /// A safe representation of community, without the sensitive info
35 #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
36 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
37 #[cfg_attr(feature = "full", table_name = "community")]
38 pub struct CommunitySafe {
42 pub description: Option<String>,
44 pub published: chrono::NaiveDateTime,
45 pub updated: Option<chrono::NaiveDateTime>,
50 pub icon: Option<DbUrl>,
51 pub banner: Option<DbUrl>,
53 pub posting_restricted_to_mods: bool,
56 #[derive(Debug, Default)]
57 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
58 #[cfg_attr(feature = "full", table_name = "community")]
59 pub struct CommunityForm {
62 pub description: 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: 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>,
82 #[derive(PartialEq, Debug)]
83 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
84 #[cfg_attr(feature = "full", belongs_to(Community))]
85 #[cfg_attr(feature = "full", table_name = "community_moderator")]
86 pub struct CommunityModerator {
88 pub community_id: CommunityId,
89 pub person_id: PersonId,
90 pub published: chrono::NaiveDateTime,
94 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
95 #[cfg_attr(feature = "full", table_name = "community_moderator")]
96 pub struct CommunityModeratorForm {
97 pub community_id: CommunityId,
98 pub person_id: PersonId,
101 #[derive(PartialEq, Debug)]
102 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
103 #[cfg_attr(feature = "full", belongs_to(Community))]
104 #[cfg_attr(feature = "full", table_name = "community_person_ban")]
105 pub struct CommunityPersonBan {
107 pub community_id: CommunityId,
108 pub person_id: PersonId,
109 pub published: chrono::NaiveDateTime,
110 pub expires: Option<chrono::NaiveDateTime>,
114 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
115 #[cfg_attr(feature = "full", table_name = "community_person_ban")]
116 pub struct CommunityPersonBanForm {
117 pub community_id: CommunityId,
118 pub person_id: PersonId,
119 pub expires: Option<Option<chrono::NaiveDateTime>>,
122 #[derive(PartialEq, Debug)]
123 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
124 #[cfg_attr(feature = "full", belongs_to(Community))]
125 #[cfg_attr(feature = "full", table_name = "community_follower")]
126 pub struct CommunityFollower {
128 pub community_id: CommunityId,
129 pub person_id: PersonId,
130 pub published: chrono::NaiveDateTime,
135 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
136 #[cfg_attr(feature = "full", table_name = "community_follower")]
137 pub struct CommunityFollowerForm {
138 pub community_id: CommunityId,
139 pub person_id: PersonId,