2022-10-27 09:24:07 +00:00
|
|
|
use crate::newtypes::InstanceId;
|
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use crate::schema::instance;
|
2023-02-18 14:36:12 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
use serde_with::skip_serializing_none;
|
2022-11-02 19:18:22 +00:00
|
|
|
use std::fmt::Debug;
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2023-02-18 14:36:12 +00:00
|
|
|
use typed_builder::TypedBuilder;
|
2022-10-27 09:24:07 +00:00
|
|
|
|
2023-04-26 04:26:10 +00:00
|
|
|
#[skip_serializing_none]
|
2023-02-18 14:36:12 +00:00
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Queryable, Identifiable, TS))]
|
2022-10-27 09:24:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = instance))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// A federated instance / site.
|
2022-10-27 09:24:07 +00:00
|
|
|
pub struct Instance {
|
|
|
|
pub id: InstanceId,
|
|
|
|
pub domain: String,
|
|
|
|
pub published: chrono::NaiveDateTime,
|
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
2023-04-17 19:19:51 +00:00
|
|
|
pub software: Option<String>,
|
|
|
|
pub version: Option<String>,
|
2022-10-27 09:24:07 +00:00
|
|
|
}
|
|
|
|
|
2023-02-18 14:36:12 +00:00
|
|
|
#[derive(Clone, TypedBuilder)]
|
|
|
|
#[builder(field_defaults(default))]
|
2022-10-27 09:24:07 +00:00
|
|
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = instance))]
|
|
|
|
pub struct InstanceForm {
|
2023-02-18 14:36:12 +00:00
|
|
|
#[builder(!default)]
|
2022-10-27 09:24:07 +00:00
|
|
|
pub domain: String,
|
2023-02-18 14:36:12 +00:00
|
|
|
pub software: Option<String>,
|
|
|
|
pub version: Option<String>,
|
2022-10-27 09:24:07 +00:00
|
|
|
pub updated: Option<chrono::NaiveDateTime>,
|
|
|
|
}
|