fix: oops go back must be generic object

This commit is contained in:
əlemi 2024-07-15 21:54:40 +02:00
parent bad86f5bcf
commit 9d2996dece
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,6 +1,6 @@
use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns}; use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns};
use apb::{ActorMut, ActorType, BaseMut, DocumentMut, EndpointsMut, ObjectMut, PublicKeyMut}; use apb::{field::OptionalString, ActorMut, ActorType, BaseMut, DocumentMut, EndpointsMut, ObjectMut, PublicKeyMut};
use crate::ext::{JsonVec, TypeName}; use crate::ext::{JsonVec, TypeName};
@ -22,11 +22,11 @@ impl TypeName for Field {
} }
} }
impl From<serde_json::Value> for Field { impl<T: apb::Object> From<T> for Field {
fn from(value: serde_json::Value) -> Self { fn from(value: T) -> Self {
Field { Field {
name: value.get("name").and_then(|x| x.as_str()).unwrap_or_default().to_string(), name: value.name().str().unwrap_or_default(),
value: value.get("value").and_then(|x| x.as_str()).unwrap_or_default().to_string(), value: value.value().str().unwrap_or_default(),
field_type: "PropertyValue".to_string(), // TODO can we try parsing this instead?? field_type: "PropertyValue".to_string(), // TODO can we try parsing this instead??
verified_at: None, // TODO where does verified_at come from? extend apb maybe verified_at: None, // TODO where does verified_at come from? extend apb maybe
} }