Actually serialize posts in outbox
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use chrono;
|
||||
use diesel::PgConnection;
|
||||
use serde_json;
|
||||
|
||||
@@ -13,28 +14,31 @@ impl Activity {
|
||||
match self {
|
||||
Activity::Create(data) => json!({
|
||||
"type": "Create",
|
||||
"by": data.by,
|
||||
"object": data.object
|
||||
"actor": data.by,
|
||||
"object": data.object,
|
||||
"published": data.date.to_rfc3339()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create<T: Object, U: Actor>(by: &U, obj: T, conn: &PgConnection) -> Activity {
|
||||
Activity::Create(CreatePayload::new(serde_json::Value::String(by.compute_id(conn)), obj.serialize()))
|
||||
Activity::Create(CreatePayload::new(serde_json::Value::String(by.compute_id(conn)), obj.serialize(conn)))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CreatePayload {
|
||||
by: serde_json::Value,
|
||||
object: serde_json::Value
|
||||
object: serde_json::Value,
|
||||
date: chrono::DateTime<chrono::Utc>
|
||||
}
|
||||
|
||||
impl CreatePayload {
|
||||
pub fn new(by: serde_json::Value, obj: serde_json::Value) -> CreatePayload {
|
||||
CreatePayload {
|
||||
by: by,
|
||||
object: obj
|
||||
object: obj,
|
||||
date: chrono::Utc::now()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ pub mod webfinger;
|
||||
pub type ActivityPub = Content<Json>;
|
||||
|
||||
pub const CONTEXT_URL: &'static str = "https://www.w3.org/ns/activitystreams";
|
||||
pub const PUBLIC_VISIBILTY: &'static str = "https://www.w3.org/ns/activitystreams#Public";
|
||||
|
||||
pub fn context() -> serde_json::Value {
|
||||
json!([
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use diesel::PgConnection;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::actor::Actor;
|
||||
|
||||
pub trait Object {
|
||||
fn serialize(&self) -> serde_json::Value;
|
||||
fn serialize(&self, conn: &PgConnection) -> serde_json::Value;
|
||||
}
|
||||
|
||||
pub trait Attribuable {
|
||||
|
||||
Reference in New Issue
Block a user