]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/person.rs
Merge pull request #1499 from LemmyNet/strictly_type_db_ids
[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 }
29
30 /// A safe representation of person, without the sensitive info
31 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
32 #[table_name = "person"]
33 pub struct PersonSafe {
34   pub id: PersonId,
35   pub name: String,
36   pub preferred_username: Option<String>,
37   pub avatar: Option<DbUrl>,
38   pub banned: bool,
39   pub published: chrono::NaiveDateTime,
40   pub updated: Option<chrono::NaiveDateTime>,
41   pub actor_id: DbUrl,
42   pub bio: Option<String>,
43   pub local: bool,
44   pub banner: Option<DbUrl>,
45   pub deleted: bool,
46   pub inbox_url: DbUrl,
47   pub shared_inbox_url: Option<DbUrl>,
48 }
49
50 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
51 #[table_name = "person_alias_1"]
52 pub struct PersonAlias1 {
53   pub id: PersonId,
54   pub name: String,
55   pub preferred_username: Option<String>,
56   pub avatar: Option<DbUrl>,
57   pub banned: bool,
58   pub published: chrono::NaiveDateTime,
59   pub updated: Option<chrono::NaiveDateTime>,
60   pub actor_id: DbUrl,
61   pub bio: Option<String>,
62   pub local: bool,
63   pub private_key: Option<String>,
64   pub public_key: Option<String>,
65   pub last_refreshed_at: chrono::NaiveDateTime,
66   pub banner: Option<DbUrl>,
67   pub deleted: bool,
68   pub inbox_url: DbUrl,
69   pub shared_inbox_url: Option<DbUrl>,
70 }
71
72 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
73 #[table_name = "person_alias_1"]
74 pub struct PersonSafeAlias1 {
75   pub id: PersonId,
76   pub name: String,
77   pub preferred_username: Option<String>,
78   pub avatar: Option<DbUrl>,
79   pub banned: bool,
80   pub published: chrono::NaiveDateTime,
81   pub updated: Option<chrono::NaiveDateTime>,
82   pub actor_id: DbUrl,
83   pub bio: Option<String>,
84   pub local: bool,
85   pub banner: Option<DbUrl>,
86   pub deleted: bool,
87   pub inbox_url: DbUrl,
88   pub shared_inbox_url: Option<DbUrl>,
89 }
90
91 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
92 #[table_name = "person_alias_2"]
93 pub struct PersonAlias2 {
94   pub id: PersonId,
95   pub name: String,
96   pub preferred_username: Option<String>,
97   pub avatar: Option<DbUrl>,
98   pub banned: bool,
99   pub published: chrono::NaiveDateTime,
100   pub updated: Option<chrono::NaiveDateTime>,
101   pub actor_id: DbUrl,
102   pub bio: Option<String>,
103   pub local: bool,
104   pub private_key: Option<String>,
105   pub public_key: Option<String>,
106   pub last_refreshed_at: chrono::NaiveDateTime,
107   pub banner: Option<DbUrl>,
108   pub deleted: bool,
109   pub inbox_url: DbUrl,
110   pub shared_inbox_url: Option<DbUrl>,
111 }
112
113 #[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
114 #[table_name = "person_alias_1"]
115 pub struct PersonSafeAlias2 {
116   pub id: PersonId,
117   pub name: String,
118   pub preferred_username: Option<String>,
119   pub avatar: Option<DbUrl>,
120   pub banned: bool,
121   pub published: chrono::NaiveDateTime,
122   pub updated: Option<chrono::NaiveDateTime>,
123   pub actor_id: DbUrl,
124   pub bio: Option<String>,
125   pub local: bool,
126   pub banner: Option<DbUrl>,
127   pub deleted: bool,
128   pub inbox_url: DbUrl,
129   pub shared_inbox_url: Option<DbUrl>,
130 }
131
132 #[derive(Insertable, AsChangeset, Clone)]
133 #[table_name = "person"]
134 pub struct PersonForm {
135   pub name: String,
136   pub preferred_username: Option<Option<String>>,
137   pub avatar: Option<Option<DbUrl>>,
138   pub banned: Option<bool>,
139   pub published: Option<chrono::NaiveDateTime>,
140   pub updated: Option<chrono::NaiveDateTime>,
141   pub actor_id: Option<DbUrl>,
142   pub bio: Option<Option<String>>,
143   pub local: Option<bool>,
144   pub private_key: Option<Option<String>>,
145   pub public_key: Option<Option<String>>,
146   pub last_refreshed_at: Option<chrono::NaiveDateTime>,
147   pub banner: Option<Option<DbUrl>>,
148   pub deleted: Option<bool>,
149   pub inbox_url: Option<DbUrl>,
150   pub shared_inbox_url: Option<Option<DbUrl>>,
151 }