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,
100 #[derive(Insertable, AsChangeset, Clone)]
101 #[table_name = "community_person_ban"]
102 pub struct CommunityPersonBanForm {
103 pub community_id: CommunityId,
104 pub person_id: PersonId,
107 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
108 #[belongs_to(Community)]
109 #[table_name = "community_follower"]
110 pub struct CommunityFollower {
112 pub community_id: CommunityId,
113 pub person_id: PersonId,
114 pub published: chrono::NaiveDateTime,
115 pub pending: Option<bool>,
118 #[derive(Insertable, AsChangeset, Clone)]
119 #[table_name = "community_follower"]
120 pub struct CommunityFollowerForm {
121 pub community_id: CommunityId,
122 pub person_id: PersonId,