]> Untitled Git - lemmy.git/blob - crates/db_schema/src/source/instance.rs
Split activity table into sent and received parts (fixes #3103) (#3583)
[lemmy.git] / crates / db_schema / src / source / instance.rs
1 use crate::newtypes::InstanceId;
2 #[cfg(feature = "full")]
3 use crate::schema::instance;
4 use serde::{Deserialize, Serialize};
5 use serde_with::skip_serializing_none;
6 use std::fmt::Debug;
7 #[cfg(feature = "full")]
8 use ts_rs::TS;
9 use typed_builder::TypedBuilder;
10
11 #[skip_serializing_none]
12 #[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
13 #[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
14 #[cfg_attr(feature = "full", diesel(table_name = instance))]
15 #[cfg_attr(feature = "full", ts(export))]
16 /// A federated instance / site.
17 pub struct Instance {
18   pub id: InstanceId,
19   pub domain: String,
20   pub published: chrono::NaiveDateTime,
21   pub updated: Option<chrono::NaiveDateTime>,
22   pub software: Option<String>,
23   pub version: Option<String>,
24 }
25
26 #[derive(Clone, TypedBuilder)]
27 #[builder(field_defaults(default))]
28 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
29 #[cfg_attr(feature = "full", diesel(table_name = instance))]
30 pub struct InstanceForm {
31   #[builder(!default)]
32   pub domain: String,
33   pub software: Option<String>,
34   pub version: Option<String>,
35   pub updated: Option<chrono::NaiveDateTime>,
36 }