2 newtypes::{CommunityId, DbUrl, PersonId},
3 schema::{community, community_follower, community_moderator, community_person_ban},
5 use serde::{Deserialize, Serialize};
7 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
8 #[table_name = "community"]
13 pub description: Option<String>,
15 pub published: chrono::NaiveDateTime,
16 pub updated: Option<chrono::NaiveDateTime>,
21 pub private_key: Option<String>,
22 pub public_key: String,
23 pub last_refreshed_at: chrono::NaiveDateTime,
24 pub icon: Option<DbUrl>,
25 pub banner: Option<DbUrl>,
26 pub followers_url: DbUrl,
28 pub shared_inbox_url: Option<DbUrl>,
30 pub posting_restricted_to_mods: bool,
33 /// A safe representation of community, without the sensitive info
34 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
35 #[table_name = "community"]
36 pub struct CommunitySafe {
40 pub description: Option<String>,
42 pub published: chrono::NaiveDateTime,
43 pub updated: Option<chrono::NaiveDateTime>,
48 pub icon: Option<DbUrl>,
49 pub banner: Option<DbUrl>,
51 pub posting_restricted_to_mods: bool,
54 #[derive(Insertable, AsChangeset, Debug, Default)]
55 #[table_name = "community"]
56 pub struct CommunityForm {
59 pub description: Option<String>,
60 pub removed: Option<bool>,
61 pub published: Option<chrono::NaiveDateTime>,
62 pub updated: Option<chrono::NaiveDateTime>,
63 pub deleted: Option<bool>,
64 pub nsfw: Option<bool>,
65 pub actor_id: Option<DbUrl>,
66 pub local: Option<bool>,
67 pub private_key: Option<Option<String>>,
68 pub public_key: String,
69 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
70 pub icon: Option<Option<DbUrl>>,
71 pub banner: Option<Option<DbUrl>>,
72 pub followers_url: Option<DbUrl>,
73 pub inbox_url: Option<DbUrl>,
74 pub shared_inbox_url: Option<Option<DbUrl>>,
75 pub hidden: Option<bool>,
76 pub posting_restricted_to_mods: Option<bool>,
79 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
80 #[belongs_to(Community)]
81 #[table_name = "community_moderator"]
82 pub struct CommunityModerator {
84 pub community_id: CommunityId,
85 pub person_id: PersonId,
86 pub published: chrono::NaiveDateTime,
89 #[derive(Insertable, AsChangeset, Clone)]
90 #[table_name = "community_moderator"]
91 pub struct CommunityModeratorForm {
92 pub community_id: CommunityId,
93 pub person_id: PersonId,
96 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
97 #[belongs_to(Community)]
98 #[table_name = "community_person_ban"]
99 pub struct CommunityPersonBan {
101 pub community_id: CommunityId,
102 pub person_id: PersonId,
103 pub published: chrono::NaiveDateTime,
104 pub expires: Option<chrono::NaiveDateTime>,
107 #[derive(Insertable, AsChangeset, Clone)]
108 #[table_name = "community_person_ban"]
109 pub struct CommunityPersonBanForm {
110 pub community_id: CommunityId,
111 pub person_id: PersonId,
112 pub expires: Option<Option<chrono::NaiveDateTime>>,
115 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
116 #[belongs_to(Community)]
117 #[table_name = "community_follower"]
118 pub struct CommunityFollower {
120 pub community_id: CommunityId,
121 pub person_id: PersonId,
122 pub published: chrono::NaiveDateTime,
123 pub pending: Option<bool>,
126 #[derive(Insertable, AsChangeset, Clone)]
127 #[table_name = "community_follower"]
128 pub struct CommunityFollowerForm {
129 pub community_id: CommunityId,
130 pub person_id: PersonId,