Compare commits
No commits in common. "9d2996dece6bda542acf66c291d37f5c241fd2b5" and "8e9695c1d5378a01012fbb3e4530b4d018171e60" have entirely different histories.
9d2996dece
...
8e9695c1d5
3 changed files with 5 additions and 21 deletions
|
@ -1,13 +1,9 @@
|
|||
/// ActivityPub object node, representing either nothing, something, a link to something or
|
||||
/// multiple things
|
||||
pub enum Node<T : super::Base> {
|
||||
/// this document node holds multiple objects
|
||||
Array(std::collections::VecDeque<Node<T>>), // TODO would be cool to make it Box<[T]> so that Node is just a ptr
|
||||
/// this document node holds one object
|
||||
Object(Box<T>),
|
||||
/// this document node holds a reference to an object
|
||||
Link(Box<dyn crate::Link + Sync + Send>), // TODO feature flag to toggle these maybe?
|
||||
/// this document node is not present
|
||||
Empty,
|
||||
}
|
||||
|
||||
|
|
|
@ -127,9 +127,6 @@ pub trait Object : Base {
|
|||
fn as_actor(&self) -> Result<&Self::Actor, FieldErr> { Err(FieldErr("type")) }
|
||||
fn as_collection(&self) -> Result<&Self::Collection, FieldErr> { Err(FieldErr("type")) }
|
||||
fn as_document(&self) -> Result<&Self::Document, FieldErr> { Err(FieldErr("type")) }
|
||||
|
||||
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
|
||||
fn value(&self) -> Field<&str> { Err(FieldErr("value")) }
|
||||
}
|
||||
|
||||
pub trait ObjectMut : BaseMut {
|
||||
|
@ -179,9 +176,6 @@ pub trait ObjectMut : BaseMut {
|
|||
|
||||
#[cfg(feature = "ostatus")]
|
||||
fn set_conversation(self, val: Node<Self::Object>) -> Self;
|
||||
|
||||
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
|
||||
fn set_value(self, val: Option<&str>) -> Self;
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstructured")]
|
||||
|
@ -234,9 +228,6 @@ impl Object for serde_json::Value {
|
|||
#[cfg(feature = "ostatus")]
|
||||
crate::getter! { conversation -> node <Self as Object>::Object }
|
||||
|
||||
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
|
||||
crate::getter! { value -> &str }
|
||||
|
||||
fn as_activity(&self) -> Result<&Self::Activity, FieldErr> {
|
||||
match self.object_type()? {
|
||||
ObjectType::Activity(_) => Ok(self),
|
||||
|
@ -314,7 +305,4 @@ impl ObjectMut for serde_json::Value {
|
|||
|
||||
#[cfg(feature = "ostatus")]
|
||||
crate::setter! { conversation -> node <Self as Object>::Object }
|
||||
|
||||
#[cfg(feature = "did-core")] // TODO this isn't from did-core actually!?!?!?!?!
|
||||
crate::setter! { value -> &str }
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use sea_orm::{entity::prelude::*, QuerySelect, SelectColumns};
|
||||
|
||||
use apb::{field::OptionalString, ActorMut, ActorType, BaseMut, DocumentMut, EndpointsMut, ObjectMut, PublicKeyMut};
|
||||
use apb::{ActorMut, ActorType, BaseMut, DocumentMut, EndpointsMut, ObjectMut, PublicKeyMut};
|
||||
|
||||
use crate::ext::{JsonVec, TypeName};
|
||||
|
||||
|
@ -22,11 +22,11 @@ impl TypeName for Field {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: apb::Object> From<T> for Field {
|
||||
fn from(value: T) -> Self {
|
||||
impl From<serde_json::Value> for Field {
|
||||
fn from(value: serde_json::Value) -> Self {
|
||||
Field {
|
||||
name: value.name().str().unwrap_or_default(),
|
||||
value: value.value().str().unwrap_or_default(),
|
||||
name: value.get("name").and_then(|x| x.as_str()).unwrap_or_default().to_string(),
|
||||
value: value.get("value").and_then(|x| x.as_str()).unwrap_or_default().to_string(),
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue