1 use crate::newtypes::{CommunityId, DbUrl, InstanceId, PersonId};
2 #[cfg(feature = "full")]
3 use crate::schema::{community, community_follower, community_moderator, community_person_ban};
4 use serde::{Deserialize, Serialize};
5 use typed_builder::TypedBuilder;
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>,
23 pub private_key: Option<String>,
25 pub public_key: String,
27 pub last_refreshed_at: chrono::NaiveDateTime,
28 pub icon: Option<DbUrl>,
29 pub banner: Option<DbUrl>,
30 #[serde(skip_serializing)]
31 pub followers_url: DbUrl,
32 #[serde(skip_serializing)]
35 pub shared_inbox_url: Option<DbUrl>,
36 /// Url where moderators collection is served over Activitypub
38 pub moderators_url: Option<DbUrl>,
39 /// Url where featured posts collection is served over Activitypub
41 pub featured_url: Option<DbUrl>,
43 pub posting_restricted_to_mods: bool,
44 pub instance_id: InstanceId,
47 #[derive(Debug, Clone, TypedBuilder)]
48 #[builder(field_defaults(default))]
49 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
50 #[cfg_attr(feature = "full", diesel(table_name = community))]
51 pub struct CommunityInsertForm {
56 pub description: Option<String>,
57 pub removed: Option<bool>,
58 pub published: Option<chrono::NaiveDateTime>,
59 pub updated: Option<chrono::NaiveDateTime>,
60 pub deleted: Option<bool>,
61 pub nsfw: Option<bool>,
62 pub actor_id: Option<DbUrl>,
63 pub local: Option<bool>,
64 pub private_key: Option<String>,
65 pub public_key: String,
66 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
67 pub icon: Option<DbUrl>,
68 pub banner: Option<DbUrl>,
69 pub followers_url: Option<DbUrl>,
70 pub inbox_url: Option<DbUrl>,
71 pub shared_inbox_url: Option<DbUrl>,
72 pub moderators_url: Option<DbUrl>,
73 pub featured_url: Option<DbUrl>,
74 pub hidden: Option<bool>,
75 pub posting_restricted_to_mods: Option<bool>,
77 pub instance_id: InstanceId,
80 #[derive(Debug, Clone, TypedBuilder)]
81 #[builder(field_defaults(default))]
82 #[cfg_attr(feature = "full", derive(AsChangeset))]
83 #[cfg_attr(feature = "full", diesel(table_name = community))]
84 pub struct CommunityUpdateForm {
85 pub title: Option<String>,
86 pub description: Option<Option<String>>,
87 pub removed: Option<bool>,
88 pub published: Option<chrono::NaiveDateTime>,
89 pub updated: Option<Option<chrono::NaiveDateTime>>,
90 pub deleted: Option<bool>,
91 pub nsfw: Option<bool>,
92 pub actor_id: Option<DbUrl>,
93 pub local: Option<bool>,
94 pub public_key: Option<String>,
95 pub private_key: Option<Option<String>>,
96 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
97 pub icon: Option<Option<DbUrl>>,
98 pub banner: Option<Option<DbUrl>>,
99 pub followers_url: Option<DbUrl>,
100 pub inbox_url: Option<DbUrl>,
101 pub shared_inbox_url: Option<Option<DbUrl>>,
102 pub moderators_url: Option<DbUrl>,
103 pub featured_url: Option<DbUrl>,
104 pub hidden: Option<bool>,
105 pub posting_restricted_to_mods: Option<bool>,
108 #[derive(PartialEq, Eq, Debug)]
109 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
112 diesel(belongs_to(crate::source::community::Community))
114 #[cfg_attr(feature = "full", diesel(table_name = community_moderator))]
115 pub struct CommunityModerator {
117 pub community_id: CommunityId,
118 pub person_id: PersonId,
119 pub published: chrono::NaiveDateTime,
123 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
124 #[cfg_attr(feature = "full", diesel(table_name = community_moderator))]
125 pub struct CommunityModeratorForm {
126 pub community_id: CommunityId,
127 pub person_id: PersonId,
130 #[derive(PartialEq, Eq, Debug)]
131 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
134 diesel(belongs_to(crate::source::community::Community))
136 #[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
137 pub struct CommunityPersonBan {
139 pub community_id: CommunityId,
140 pub person_id: PersonId,
141 pub published: chrono::NaiveDateTime,
142 pub expires: Option<chrono::NaiveDateTime>,
146 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
147 #[cfg_attr(feature = "full", diesel(table_name = community_person_ban))]
148 pub struct CommunityPersonBanForm {
149 pub community_id: CommunityId,
150 pub person_id: PersonId,
151 pub expires: Option<Option<chrono::NaiveDateTime>>,
154 #[derive(PartialEq, Eq, Debug)]
155 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
158 diesel(belongs_to(crate::source::community::Community))
160 #[cfg_attr(feature = "full", diesel(table_name = community_follower))]
161 pub struct CommunityFollower {
163 pub community_id: CommunityId,
164 pub person_id: PersonId,
165 pub published: chrono::NaiveDateTime,
170 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
171 #[cfg_attr(feature = "full", diesel(table_name = community_follower))]
172 pub struct CommunityFollowerForm {
173 pub community_id: CommunityId,
174 pub person_id: PersonId,