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, 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 {
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, 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 {
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", diesel(table_name = community))]
59 pub struct CommunityForm {
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>,
82 #[derive(PartialEq, Eq, Debug)]
83 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
86 diesel(belongs_to(crate::source::community::Community))
88 #[cfg_attr(feature = "full", diesel(table_name = community_moderator))]
89 pub struct CommunityModerator {
91 pub community_id: CommunityId,
92 pub person_id: PersonId,
93 pub published: chrono::NaiveDateTime,
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,
104 #[derive(PartialEq, Eq, Debug)]
105 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
108 diesel(belongs_to(crate::source::community::Community))
110 #[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
111 pub struct CommunityPersonBan {
113 pub community_id: CommunityId,
114 pub person_id: PersonId,
115 pub published: chrono::NaiveDateTime,
116 pub expires: Option<chrono::NaiveDateTime>,
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>>,
128 #[derive(PartialEq, Eq, Debug)]
129 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
132 diesel(belongs_to(crate::source::community::Community))
134 #[cfg_attr(feature = "full", diesel(table_name = community_follower))]
135 pub struct CommunityFollower {
137 pub community_id: CommunityId,
138 pub person_id: PersonId,
139 pub published: chrono::NaiveDateTime,
140 pub pending: Option<bool>,
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,