1 use crate::newtypes::{DbUrl, InstanceId, SiteId};
2 use serde::{Deserialize, Serialize};
3 use typed_builder::TypedBuilder;
5 #[cfg(feature = "full")]
6 use crate::schema::site;
8 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
10 #[cfg_attr(feature = "full", diesel(table_name = site))]
14 pub sidebar: Option<String>,
15 pub published: chrono::NaiveDateTime,
16 pub updated: Option<chrono::NaiveDateTime>,
17 pub icon: Option<DbUrl>,
18 pub banner: Option<DbUrl>,
19 pub description: Option<String>,
21 pub last_refreshed_at: chrono::NaiveDateTime,
23 pub private_key: Option<String>,
24 pub public_key: String,
25 pub instance_id: InstanceId,
28 #[derive(Clone, TypedBuilder)]
29 #[builder(field_defaults(default))]
30 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
31 #[cfg_attr(feature = "full", diesel(table_name = site))]
32 pub struct SiteInsertForm {
35 pub sidebar: Option<String>,
36 pub updated: Option<chrono::NaiveDateTime>,
37 pub icon: Option<DbUrl>,
38 pub banner: Option<DbUrl>,
39 pub description: Option<String>,
40 pub actor_id: Option<DbUrl>,
41 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
42 pub inbox_url: Option<DbUrl>,
43 pub private_key: Option<String>,
44 pub public_key: Option<String>,
46 pub instance_id: InstanceId,
49 #[derive(Clone, TypedBuilder)]
50 #[builder(field_defaults(default))]
51 #[cfg_attr(feature = "full", derive(AsChangeset))]
52 #[cfg_attr(feature = "full", diesel(table_name = site))]
53 pub struct SiteUpdateForm {
54 pub name: Option<String>,
55 pub sidebar: Option<Option<String>>,
56 pub updated: Option<Option<chrono::NaiveDateTime>>,
57 // when you want to null out a column, you have to send Some(None)), since sending None means you just don't want to update that column.
58 pub icon: Option<Option<DbUrl>>,
59 pub banner: Option<Option<DbUrl>>,
60 pub description: Option<Option<String>>,
61 pub actor_id: Option<DbUrl>,
62 pub last_refreshed_at: Option<chrono::NaiveDateTime>,
63 pub inbox_url: Option<DbUrl>,
64 pub private_key: Option<Option<String>>,
65 pub public_key: Option<String>,