]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
Making public key required. Fixes #1934
[lemmy.git] / crates / db_schema / src / source / person.rs
1 use crate::{
2   newtypes::{DbUrl, PersonId},
3   schema::{person, person_alias_1, person_alias_2},
4 };
5 use serde::{Deserialize, Serialize};
6
7 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
8 #[table_name = "person"]
9 pub struct Person {
10   pub id: PersonId,
11   pub name: String,
12   pub display_name: Option<String>,
13   pub avatar: Option<DbUrl>,
14   pub banned: bool,
15   pub published: chrono::NaiveDateTime,
16   pub updated: Option<chrono::NaiveDateTime>,
17   pub actor_id: DbUrl,
18   pub bio: Option<String>,
19   pub local: bool,
20   pub private_key: Option<String>,
21   pub public_key: String,
22   pub last_refreshed_at: chrono::NaiveDateTime,
23   pub banner: Option<DbUrl>,
24   pub deleted: bool,
25   pub inbox_url: DbUrl,
26   pub shared_inbox_url: Option<DbUrl>,
27   pub matrix_user_id: Option<String>,
28   pub admin: bool,
29   pub bot_account: bool,
30 }
31
32 /// A safe representation of person, without the sensitive info
33 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
34 #[table_name = "person"]
35 pub struct PersonSafe {
36   pub id: PersonId,
37   pub name: String,
38   pub display_name: Option<String>,
39   pub avatar: Option<DbUrl>,
40   pub banned: bool,
41   pub published: chrono::NaiveDateTime,
42   pub updated: Option<chrono::NaiveDateTime>,
43   pub actor_id: DbUrl,
44   pub bio: Option<String>,
45   pub local: bool,
46   pub banner: Option<DbUrl>,
47   pub deleted: bool,
48   pub inbox_url: DbUrl,
49   pub shared_inbox_url: Option<DbUrl>,
50   pub matrix_user_id: Option<String>,
51   pub admin: bool,
52   pub bot_account: bool,
53 }
54
55 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
56 #[table_name = "person_alias_1"]
57 pub struct PersonAlias1 {
58   pub id: PersonId,
59   pub name: String,
60   pub display_name: Option<String>,
61   pub avatar: Option<DbUrl>,
62   pub banned: bool,
63   pub published: chrono::NaiveDateTime,
64   pub updated: Option<chrono::NaiveDateTime>,
65   pub actor_id: DbUrl,
66   pub bio: Option<String>,
67   pub local: bool,
68   pub private_key: Option<String>,
69   pub public_key: String,
70   pub last_refreshed_at: chrono::NaiveDateTime,
71   pub banner: Option<DbUrl>,
72   pub deleted: bool,
73   pub inbox_url: DbUrl,
74   pub shared_inbox_url: Option<DbUrl>,
75   pub matrix_user_id: Option<String>,
76   pub admin: bool,
77   pub bot_account: bool,
78 }
79
80 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
81 #[table_name = "person_alias_1"]
82 pub struct PersonSafeAlias1 {
83   pub id: PersonId,
84   pub name: String,
85   pub display_name: Option<String>,
86   pub avatar: Option<DbUrl>,
87   pub banned: bool,
88   pub published: chrono::NaiveDateTime,
89   pub updated: Option<chrono::NaiveDateTime>,
90   pub actor_id: DbUrl,
91   pub bio: Option<String>,
92   pub local: bool,
93   pub banner: Option<DbUrl>,
94   pub deleted: bool,
95   pub inbox_url: DbUrl,
96   pub shared_inbox_url: Option<DbUrl>,
97   pub matrix_user_id: Option<String>,
98   pub admin: bool,
99   pub bot_account: bool,
100 }
101
102 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
103 #[table_name = "person_alias_2"]
104 pub struct PersonAlias2 {
105   pub id: PersonId,
106   pub name: String,
107   pub display_name: Option<String>,
108   pub avatar: Option<DbUrl>,
109   pub banned: bool,
110   pub published: chrono::NaiveDateTime,
111   pub updated: Option<chrono::NaiveDateTime>,
112   pub actor_id: DbUrl,
113   pub bio: Option<String>,
114   pub local: bool,
115   pub private_key: Option<String>,
116   pub public_key: String,
117   pub last_refreshed_at: chrono::NaiveDateTime,
118   pub banner: Option<DbUrl>,
119   pub deleted: bool,
120   pub inbox_url: DbUrl,
121   pub shared_inbox_url: Option<DbUrl>,
122   pub matrix_user_id: Option<String>,
123   pub admin: bool,
124   pub bot_account: bool,
125 }
126
127 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
128 #[table_name = "person_alias_1"]
129 pub struct PersonSafeAlias2 {
130   pub id: PersonId,
131   pub name: String,
132   pub display_name: Option<String>,
133   pub avatar: Option<DbUrl>,
134   pub banned: bool,
135   pub published: chrono::NaiveDateTime,
136   pub updated: Option<chrono::NaiveDateTime>,
137   pub actor_id: DbUrl,
138   pub bio: Option<String>,
139   pub local: bool,
140   pub banner: Option<DbUrl>,
141   pub deleted: bool,
142   pub inbox_url: DbUrl,
143   pub shared_inbox_url: Option<DbUrl>,
144   pub matrix_user_id: Option<String>,
145   pub admin: bool,
146   pub bot_account: bool,
147 }
148
149 #[derive(Insertable, AsChangeset, Clone, Default)]
150 #[table_name = "person"]
151 pub struct PersonForm {
152   pub name: String,
153   pub display_name: Option<Option<String>>,
154   pub avatar: Option<Option<DbUrl>>,
155   pub banned: Option<bool>,
156   pub published: Option<chrono::NaiveDateTime>,
157   pub updated: Option<chrono::NaiveDateTime>,
158   pub actor_id: Option<DbUrl>,
159   pub bio: Option<Option<String>>,
160   pub local: Option<bool>,
161   pub private_key: Option<Option<String>>,
162   pub public_key: String,
163   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
164   pub banner: Option<Option<DbUrl>>,
165   pub deleted: Option<bool>,
166   pub inbox_url: Option<DbUrl>,
167   pub shared_inbox_url: Option<Option<DbUrl>>,
168   pub matrix_user_id: Option<Option<String>>,
169   pub admin: Option<bool>,
170   pub bot_account: Option<bool>,
171 }