feat: add context to objects
This commit is contained in:
parent
c4f677097b
commit
017f508907
2 changed files with 10 additions and 0 deletions
|
@ -44,6 +44,8 @@ UQIDAQAB
|
||||||
|
|
||||||
user::Entity::insert(root.clone().into_active_model()).exec(db).await?;
|
user::Entity::insert(root.clone().into_active_model()).exec(db).await?;
|
||||||
|
|
||||||
|
let context = uuid::Uuid::new_v4().to_string();
|
||||||
|
|
||||||
for i in (0..100).rev() {
|
for i in (0..100).rev() {
|
||||||
let oid = uuid::Uuid::new_v4();
|
let oid = uuid::Uuid::new_v4();
|
||||||
let aid = uuid::Uuid::new_v4();
|
let aid = uuid::Uuid::new_v4();
|
||||||
|
@ -53,6 +55,7 @@ UQIDAQAB
|
||||||
object_type: Set(crate::activitystream::object::ObjectType::Note),
|
object_type: Set(crate::activitystream::object::ObjectType::Note),
|
||||||
attributed_to: Set(Some(format!("{domain}/users/root"))),
|
attributed_to: Set(Some(format!("{domain}/users/root"))),
|
||||||
summary: Set(None),
|
summary: Set(None),
|
||||||
|
context: Set(Some(context.clone())),
|
||||||
content: Set(Some(format!("[{i}] Tic(k). Quasiparticle of intensive multiplicity. Tics (or ticks) are intrinsically several components of autonomously numbering anorganic populations, propagating by contagion between segmentary divisions in the order of nature. Ticks - as nonqualitative differentially-decomposable counting marks - each designate a multitude comprehended as a singular variation in tic(k)-density."))),
|
content: Set(Some(format!("[{i}] Tic(k). Quasiparticle of intensive multiplicity. Tics (or ticks) are intrinsically several components of autonomously numbering anorganic populations, propagating by contagion between segmentary divisions in the order of nature. Ticks - as nonqualitative differentially-decomposable counting marks - each designate a multitude comprehended as a singular variation in tic(k)-density."))),
|
||||||
published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i)),
|
published: Set(chrono::Utc::now() - std::time::Duration::from_secs(60*i)),
|
||||||
}).exec(db).await?;
|
}).exec(db).await?;
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub struct Model {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub summary: Option<String>,
|
pub summary: Option<String>,
|
||||||
pub content: Option<String>,
|
pub content: Option<String>,
|
||||||
|
pub context: Option<String>,
|
||||||
pub published: ChronoDateTimeUtc,
|
pub published: ChronoDateTimeUtc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ impl crate::activitystream::Base for Model {
|
||||||
.set_name(self.name.as_deref())
|
.set_name(self.name.as_deref())
|
||||||
.set_summary(self.summary.as_deref())
|
.set_summary(self.summary.as_deref())
|
||||||
.set_content(self.content.as_deref())
|
.set_content(self.content.as_deref())
|
||||||
|
.set_context(Node::maybe_link(self.context.clone()))
|
||||||
.set_published(Some(self.published))
|
.set_published(Some(self.published))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +87,10 @@ impl crate::activitystream::object::Object for Model {
|
||||||
self.content.as_deref()
|
self.content.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn context(&self) -> Node<impl crate::activitystream::Object> {
|
||||||
|
Node::maybe_link(self.context.clone())
|
||||||
|
}
|
||||||
|
|
||||||
fn published (&self) -> Option<chrono::DateTime<chrono::Utc>> {
|
fn published (&self) -> Option<chrono::DateTime<chrono::Utc>> {
|
||||||
Some(self.published)
|
Some(self.published)
|
||||||
}
|
}
|
||||||
|
@ -99,6 +105,7 @@ impl Model {
|
||||||
name: object.name().map(|x| x.to_string()),
|
name: object.name().map(|x| x.to_string()),
|
||||||
summary: object.summary().map(|x| x.to_string()),
|
summary: object.summary().map(|x| x.to_string()),
|
||||||
content: object.content().map(|x| x.to_string()),
|
content: object.content().map(|x| x.to_string()),
|
||||||
|
context: object.context().id().map(|x| x.to_string()),
|
||||||
published: object.published().ok_or(super::FieldError("published"))?,
|
published: object.published().ok_or(super::FieldError("published"))?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue