1
0
Fork 0
forked from alemi/upub

fix: don't clear audiences

still quite jank way to do it but at least should work again?
This commit is contained in:
əlemi 2024-04-12 21:42:06 +02:00
parent ca59c30e70
commit 5de807b3d9
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -29,15 +29,15 @@ impl From<FieldError> for axum::http::StatusCode {
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, sea_orm::FromJsonQueryResult)]
pub struct Audience(pub Vec<String>);
use apb::{Link, Node};
impl<T : Link> From<Node<T>> for Audience {
fn from(value: Node<T>) -> Self {
impl From<apb::Node<serde_json::Value>> for Audience {
fn from(value: apb::Node<serde_json::Value>) -> Self {
use apb::{Base, Link};
Audience(
match value {
Node::Empty => vec![],
Node::Link(l) => vec![l.href().to_string()],
Node::Object(o) => if let Some(id) = o.id() { vec![id.to_string()] } else { vec![] },
Node::Array(arr) => arr.into_iter().filter_map(|l| Some(l.id()?.to_string())).collect(),
apb::Node::Empty => vec![],
apb::Node::Link(l) => vec![l.href().to_string()],
apb::Node::Object(o) => if let Some(id) = o.id() { vec![id.to_string()] } else { vec![] },
apb::Node::Array(arr) => arr.into_iter().map(|l| l.href().to_string()).collect(),
}
)
}