mirror of
https://git.alemi.dev/fedicharter.git
synced 2024-11-23 00:44:48 +01:00
fix: removed broken legacy nodeinfo, fix datetime
This commit is contained in:
parent
588cc4bfbc
commit
231d27e00f
2 changed files with 5 additions and 50 deletions
|
@ -9,7 +9,7 @@ pub struct Model {
|
|||
pub id: i32,
|
||||
pub domain: String,
|
||||
pub data: String,
|
||||
pub updated: String,
|
||||
pub updated: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
|
|
@ -3,13 +3,14 @@ use serde_json::{Map, Value};
|
|||
|
||||
/// Node metadata for version detection only used for deserialization.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, PartialOrd, derive_more::Display)]
|
||||
pub(crate) enum NodeVersion {
|
||||
pub enum NodeVersion {
|
||||
V1_0 = 1000,
|
||||
V1_1 = 1001,
|
||||
V2_0 = 2000,
|
||||
V2_1 = 2001,
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub type NodeInfo<'a> = NodeInfoInternal<&'a str>;
|
||||
pub type NodeInfoOwned = NodeInfoInternal<String>;
|
||||
|
||||
|
@ -30,23 +31,6 @@ pub struct NodeInfoInternal<T> {
|
|||
pub metadata: Map<String, Value>,
|
||||
}
|
||||
|
||||
/// Node legacy metadata about a server running in the federation, only used for deserialization.
|
||||
#[derive(Debug, PartialEq, Deserialize)]
|
||||
pub(crate) struct LegacyNodeInfo<'a> {
|
||||
version: NodeVersion,
|
||||
software: Software<&'a str>,
|
||||
#[serde(default)]
|
||||
services: Services<&'a str>,
|
||||
#[serde(default)]
|
||||
protocols: Services<&'a str>,
|
||||
#[serde(rename = "openRegistrations", default)]
|
||||
open_registrations: bool,
|
||||
#[serde(default)]
|
||||
usage: Usage,
|
||||
#[serde(default)]
|
||||
metadata: Map<String, Value>,
|
||||
}
|
||||
|
||||
/// Software contains infos about software running on the node.
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Software<T> {
|
||||
|
@ -101,11 +85,12 @@ impl<'a> Services<&'a str> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
impl NodeInfo<'_> {
|
||||
/// Converts all internal `&str`s into `String`s.
|
||||
pub fn to_owned(&self) -> NodeInfoOwned {
|
||||
NodeInfoOwned {
|
||||
version: self.version.to_string(),
|
||||
version: self.version.clone(),
|
||||
software: self.software.to_owned(),
|
||||
protocols: self.protocols.iter().map(ToString::to_string).collect(),
|
||||
services: self.services.to_owned(),
|
||||
|
@ -115,33 +100,3 @@ impl NodeInfo<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<LegacyNodeInfo<'a>> for NodeInfo<'a> {
|
||||
fn from(other: LegacyNodeInfo<'a>) -> Self {
|
||||
let mut combined_protocols: Vec<&'a str> = other
|
||||
.protocols
|
||||
.inbound
|
||||
.into_iter()
|
||||
.chain(other.protocols.outbound)
|
||||
.collect();
|
||||
combined_protocols.sort();
|
||||
combined_protocols.dedup();
|
||||
|
||||
NodeInfo {
|
||||
version: other.version,
|
||||
software: other.software,
|
||||
services: other.services,
|
||||
protocols: combined_protocols,
|
||||
open_registrations: other.open_registrations,
|
||||
usage: other.usage,
|
||||
metadata: other.metadata,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<LegacyNodeInfo<'a>> for NodeInfoOwned {
|
||||
fn from(value: LegacyNodeInfo<'a>) -> Self {
|
||||
NodeInfo::from(value).to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue