1 use crate::newtypes::{DbUrl, InstanceId, PersonId};
2 #[cfg(feature = "full")]
3 use crate::schema::{person, person_follower};
4 use serde::{Deserialize, Serialize};
5 use typed_builder::TypedBuilder;
7 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
8 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
9 #[cfg_attr(feature = "full", diesel(table_name = person))]
13 pub display_name: Option<String>,
14 pub avatar: Option<DbUrl>,
16 pub published: chrono::NaiveDateTime,
17 pub updated: Option<chrono::NaiveDateTime>,
19 pub bio: Option<String>,
22 pub private_key: Option<String>,
24 pub public_key: String,
26 pub last_refreshed_at: chrono::NaiveDateTime,
27 pub banner: Option<DbUrl>,
29 #[serde(skip_serializing)]
32 pub shared_inbox_url: Option<DbUrl>,
33 pub matrix_user_id: Option<String>,
35 pub bot_account: bool,
36 pub ban_expires: Option<chrono::NaiveDateTime>,
37 pub instance_id: InstanceId,
40 #[derive(Clone, TypedBuilder)]
41 #[builder(field_defaults(default))]
42 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
43 #[cfg_attr(feature = "full", diesel(table_name = person))]
44 pub struct PersonInsertForm {
48 pub public_key: String,
50 pub instance_id: InstanceId,
51 pub display_name: Option<String>,
52 pub avatar: Option<DbUrl>,
53 pub banned: Option<bool>,
54 pub published: Option<chrono::NaiveDateTime>,
55 pub updated: Option<chrono::NaiveDateTime>,
56 pub actor_id: Option<DbUrl>,
57 pub bio: Option<String>,
58 pub local: Option<bool>,
59 pub private_key: Option<String>,
60 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
61 pub banner: Option<DbUrl>,
62 pub deleted: Option<bool>,
63 pub inbox_url: Option<DbUrl>,
64 pub shared_inbox_url: Option<DbUrl>,
65 pub matrix_user_id: Option<String>,
66 pub admin: Option<bool>,
67 pub bot_account: Option<bool>,
68 pub ban_expires: Option<chrono::NaiveDateTime>,
71 #[derive(Clone, TypedBuilder)]
72 #[cfg_attr(feature = "full", derive(AsChangeset))]
73 #[cfg_attr(feature = "full", diesel(table_name = person))]
74 #[builder(field_defaults(default))]
75 pub struct PersonUpdateForm {
76 pub display_name: Option<Option<String>>,
77 pub avatar: Option<Option<DbUrl>>,
78 pub banned: Option<bool>,
79 pub updated: Option<Option<chrono::NaiveDateTime>>,
80 pub actor_id: Option<DbUrl>,
81 pub bio: Option<Option<String>>,
82 pub local: Option<bool>,
83 pub public_key: Option<String>,
84 pub private_key: Option<Option<String>>,
85 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
86 pub banner: Option<Option<DbUrl>>,
87 pub deleted: Option<bool>,
88 pub inbox_url: Option<DbUrl>,
89 pub shared_inbox_url: Option<Option<DbUrl>>,
90 pub matrix_user_id: Option<Option<String>>,
91 pub admin: Option<bool>,
92 pub bot_account: Option<bool>,
93 pub ban_expires: Option<Option<chrono::NaiveDateTime>>,
96 #[derive(PartialEq, Eq, Debug)]
97 #[cfg_attr(feature = "full", derive(Identifiable, Queryable, Associations))]
98 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
99 #[cfg_attr(feature = "full", diesel(table_name = person_follower))]
100 pub struct PersonFollower {
102 pub person_id: PersonId,
103 pub follower_id: PersonId,
104 pub published: chrono::NaiveDateTime,
109 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
110 #[cfg_attr(feature = "full", diesel(table_name = person_follower))]
111 pub struct PersonFollowerForm {
112 pub person_id: PersonId,
113 pub follower_id: PersonId,