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>,
32 /// A safe representation of community, without the sensitive info
33 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
34 #[table_name = "community"]
35 pub struct CommunitySafe {
39 pub description: Option<String>,
41 pub published: chrono::NaiveDateTime,
42 pub updated: Option<chrono::NaiveDateTime>,
47 pub icon: Option<DbUrl>,
48 pub banner: Option<DbUrl>,
52 #[derive(Insertable, AsChangeset, Debug, Default)]
53 #[table_name = "community"]
54 pub struct CommunityForm {
57 pub description: Option<String>,
58 pub removed: Option<bool>,
59 pub published: Option<chrono::NaiveDateTime>,
60 pub updated: Option<chrono::NaiveDateTime>,
61 pub deleted: Option<bool>,
62 pub nsfw: Option<bool>,
63 pub actor_id: Option<DbUrl>,
64 pub local: Option<bool>,
65 pub private_key: Option<Option<String>>,
66 pub public_key: String,
67 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
68 pub icon: Option<Option<DbUrl>>,
69 pub banner: Option<Option<DbUrl>>,
70 pub followers_url: Option<DbUrl>,
71 pub inbox_url: Option<DbUrl>,
72 pub shared_inbox_url: Option<Option<DbUrl>>,
73 pub hidden: Option<bool>,
76 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
77 #[belongs_to(Community)]
78 #[table_name = "community_moderator"]
79 pub struct CommunityModerator {
81 pub community_id: CommunityId,
82 pub person_id: PersonId,
83 pub published: chrono::NaiveDateTime,
86 #[derive(Insertable, AsChangeset, Clone)]
87 #[table_name = "community_moderator"]
88 pub struct CommunityModeratorForm {
89 pub community_id: CommunityId,
90 pub person_id: PersonId,
93 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
94 #[belongs_to(Community)]
95 #[table_name = "community_person_ban"]
96 pub struct CommunityPersonBan {
98 pub community_id: CommunityId,
99 pub person_id: PersonId,
100 pub published: chrono::NaiveDateTime,
101 pub expires: Option<chrono::NaiveDateTime>,
104 #[derive(Insertable, AsChangeset, Clone)]
105 #[table_name = "community_person_ban"]
106 pub struct CommunityPersonBanForm {
107 pub community_id: CommunityId,
108 pub person_id: PersonId,
109 pub expires: Option<Option<chrono::NaiveDateTime>>,
112 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
113 #[belongs_to(Community)]
114 #[table_name = "community_follower"]
115 pub struct CommunityFollower {
117 pub community_id: CommunityId,
118 pub person_id: PersonId,
119 pub published: chrono::NaiveDateTime,
120 pub pending: Option<bool>,
123 #[derive(Insertable, AsChangeset, Clone)]
124 #[table_name = "community_follower"]
125 pub struct CommunityFollowerForm {
126 pub community_id: CommunityId,
127 pub person_id: PersonId,