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