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>,
31 /// A safe representation of community, without the sensitive info
32 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
33 #[table_name = "community"]
34 pub struct CommunitySafe {
38 pub description: Option<String>,
40 pub published: chrono::NaiveDateTime,
41 pub updated: Option<chrono::NaiveDateTime>,
46 pub icon: Option<DbUrl>,
47 pub banner: Option<DbUrl>,
50 #[derive(Insertable, AsChangeset, Debug, Default)]
51 #[table_name = "community"]
52 pub struct CommunityForm {
55 pub description: Option<String>,
56 pub removed: Option<bool>,
57 pub published: Option<chrono::NaiveDateTime>,
58 pub updated: Option<chrono::NaiveDateTime>,
59 pub deleted: Option<bool>,
60 pub nsfw: Option<bool>,
61 pub actor_id: Option<DbUrl>,
62 pub local: Option<bool>,
63 pub private_key: Option<Option<String>>,
64 pub public_key: String,
65 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
66 pub icon: Option<Option<DbUrl>>,
67 pub banner: Option<Option<DbUrl>>,
68 pub followers_url: Option<DbUrl>,
69 pub inbox_url: Option<DbUrl>,
70 pub shared_inbox_url: Option<Option<DbUrl>>,
73 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
74 #[belongs_to(Community)]
75 #[table_name = "community_moderator"]
76 pub struct CommunityModerator {
78 pub community_id: CommunityId,
79 pub person_id: PersonId,
80 pub published: chrono::NaiveDateTime,
83 #[derive(Insertable, AsChangeset, Clone)]
84 #[table_name = "community_moderator"]
85 pub struct CommunityModeratorForm {
86 pub community_id: CommunityId,
87 pub person_id: PersonId,
90 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
91 #[belongs_to(Community)]
92 #[table_name = "community_person_ban"]
93 pub struct CommunityPersonBan {
95 pub community_id: CommunityId,
96 pub person_id: PersonId,
97 pub published: chrono::NaiveDateTime,
98 pub expires: Option<chrono::NaiveDateTime>,
101 #[derive(Insertable, AsChangeset, Clone)]
102 #[table_name = "community_person_ban"]
103 pub struct CommunityPersonBanForm {
104 pub community_id: CommunityId,
105 pub person_id: PersonId,
106 pub expires: Option<Option<chrono::NaiveDateTime>>,
109 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
110 #[belongs_to(Community)]
111 #[table_name = "community_follower"]
112 pub struct CommunityFollower {
114 pub community_id: CommunityId,
115 pub person_id: PersonId,
116 pub published: chrono::NaiveDateTime,
117 pub pending: Option<bool>,
120 #[derive(Insertable, AsChangeset, Clone)]
121 #[table_name = "community_follower"]
122 pub struct CommunityFollowerForm {
123 pub community_id: CommunityId,
124 pub person_id: PersonId,