]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/community.rs
Removing community.creator column. Fixes #1504 (#1541)
[lemmy.git] / crates / db_schema / src / source / community.rs
1 use crate::{
2   schema::{community, community_follower, community_moderator, community_person_ban},
3   CommunityId,
4   DbUrl,
5   PersonId,
6 };
7 use serde::Serialize;
8
9 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
10 #[table_name = "community"]
11 pub struct Community {
12   pub id: CommunityId,
13   pub name: String,
14   pub title: String,
15   pub description: Option<String>,
16   pub removed: bool,
17   pub published: chrono::NaiveDateTime,
18   pub updated: Option<chrono::NaiveDateTime>,
19   pub deleted: bool,
20   pub nsfw: bool,
21   pub actor_id: DbUrl,
22   pub local: bool,
23   pub private_key: Option<String>,
24   pub public_key: Option<String>,
25   pub last_refreshed_at: chrono::NaiveDateTime,
26   pub icon: Option<DbUrl>,
27   pub banner: Option<DbUrl>,
28   pub followers_url: DbUrl,
29   pub inbox_url: DbUrl,
30   pub shared_inbox_url: Option<DbUrl>,
31 }
32
33 /// A safe representation of community, without the sensitive info
34 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
35 #[table_name = "community"]
36 pub struct CommunitySafe {
37   pub id: CommunityId,
38   pub name: String,
39   pub title: String,
40   pub description: Option<String>,
41   pub removed: bool,
42   pub published: chrono::NaiveDateTime,
43   pub updated: Option<chrono::NaiveDateTime>,
44   pub deleted: bool,
45   pub nsfw: bool,
46   pub actor_id: DbUrl,
47   pub local: bool,
48   pub icon: Option<DbUrl>,
49   pub banner: Option<DbUrl>,
50 }
51
52 #[derive(Insertable, AsChangeset, Debug, Default)]
53 #[table_name = "community"]
54 pub struct CommunityForm {
55   pub name: String,
56   pub title: String,
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<String>,
66   pub public_key: Option<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 }
74
75 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
76 #[belongs_to(Community)]
77 #[table_name = "community_moderator"]
78 pub struct CommunityModerator {
79   pub id: i32,
80   pub community_id: CommunityId,
81   pub person_id: PersonId,
82   pub published: chrono::NaiveDateTime,
83 }
84
85 #[derive(Insertable, AsChangeset, Clone)]
86 #[table_name = "community_moderator"]
87 pub struct CommunityModeratorForm {
88   pub community_id: CommunityId,
89   pub person_id: PersonId,
90 }
91
92 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
93 #[belongs_to(Community)]
94 #[table_name = "community_person_ban"]
95 pub struct CommunityPersonBan {
96   pub id: i32,
97   pub community_id: CommunityId,
98   pub person_id: PersonId,
99   pub published: chrono::NaiveDateTime,
100 }
101
102 #[derive(Insertable, AsChangeset, Clone)]
103 #[table_name = "community_person_ban"]
104 pub struct CommunityPersonBanForm {
105   pub community_id: CommunityId,
106   pub person_id: PersonId,
107 }
108
109 #[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
110 #[belongs_to(Community)]
111 #[table_name = "community_follower"]
112 pub struct CommunityFollower {
113   pub id: i32,
114   pub community_id: CommunityId,
115   pub person_id: PersonId,
116   pub published: chrono::NaiveDateTime,
117   pub pending: Option<bool>,
118 }
119
120 #[derive(Insertable, AsChangeset, Clone)]
121 #[table_name = "community_follower"]
122 pub struct CommunityFollowerForm {
123   pub community_id: CommunityId,
124   pub person_id: PersonId,
125   pub pending: bool,
126 }