1 use crate::newtypes::{DbUrl, InstanceId, SiteId};
2 #[cfg(feature = "full")]
3 use crate::schema::site;
4 use chrono::NaiveDateTime;
5 use serde::{Deserialize, Serialize};
6 use serde_with::skip_serializing_none;
7 #[cfg(feature = "full")]
9 use typed_builder::TypedBuilder;
11 #[skip_serializing_none]
12 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
13 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
14 #[cfg_attr(feature = "full", diesel(table_name = site))]
15 #[cfg_attr(feature = "full", ts(export))]
20 /// A sidebar for the site in markdown.
21 pub sidebar: Option<String>,
22 pub published: NaiveDateTime,
23 pub updated: Option<NaiveDateTime>,
25 pub icon: Option<DbUrl>,
27 pub banner: Option<DbUrl>,
28 /// A shorter, one-line description of the site.
29 pub description: Option<String>,
30 /// The federated actor_id.
32 /// The time the site was last refreshed.
33 pub last_refreshed_at: NaiveDateTime,
36 pub private_key: Option<String>,
37 pub public_key: String,
38 pub instance_id: InstanceId,
41 #[derive(Clone, TypedBuilder)]
42 #[builder(field_defaults(default))]
43 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
44 #[cfg_attr(feature = "full", diesel(table_name = site))]
45 pub struct SiteInsertForm {
48 pub sidebar: Option<String>,
49 pub updated: Option<NaiveDateTime>,
50 pub icon: Option<DbUrl>,
51 pub banner: Option<DbUrl>,
52 pub description: Option<String>,
53 pub actor_id: Option<DbUrl>,
54 pub last_refreshed_at: Option<NaiveDateTime>,
55 pub inbox_url: Option<DbUrl>,
56 pub private_key: Option<String>,
57 pub public_key: Option<String>,
59 pub instance_id: InstanceId,
62 #[derive(Clone, TypedBuilder)]
63 #[builder(field_defaults(default))]
64 #[cfg_attr(feature = "full", derive(AsChangeset))]
65 #[cfg_attr(feature = "full", diesel(table_name = site))]
66 pub struct SiteUpdateForm {
67 pub name: Option<String>,
68 pub sidebar: Option<Option<String>>,
69 pub updated: Option<Option<NaiveDateTime>>,
70 // 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.
71 pub icon: Option<Option<DbUrl>>,
72 pub banner: Option<Option<DbUrl>>,
73 pub description: Option<Option<String>>,
74 pub actor_id: Option<DbUrl>,
75 pub last_refreshed_at: Option<NaiveDateTime>,
76 pub inbox_url: Option<DbUrl>,
77 pub private_key: Option<Option<String>>,
78 pub public_key: Option<String>,