From 19291bc107a58dbfcd5298df122615fa2ff21f28 Mon Sep 17 00:00:00 2001 From: aprilthepink Date: Sat, 4 May 2024 00:00:26 +0200 Subject: [PATCH] Add url, published, and sensitive fields to Note struct in post.rs --- src/objects/post.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/objects/post.rs b/src/objects/post.rs index 67e664c..0f891d5 100644 --- a/src/objects/post.rs +++ b/src/objects/post.rs @@ -39,6 +39,9 @@ pub struct Note { content: String, in_reply_to: Option>, tag: Vec, + url: String, + published: String, + sensitive: bool, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -84,7 +87,12 @@ impl Object for post::Model { content: Set(json.content.clone()), id: Set(json.id.to_string()), creator: Set(creator.id.to_string()), + created_at: Set(chrono::Utc::now()), //TODO: make this use the real timestamp + content_type: Set("text/plain".to_string()), // TODO: make this use the real content type local: Set(false), + visibility: Set("public".to_string()), // TODO: make this use the real visibility + sensitive: Set(json.sensitive.clone()), + url: Set(json.url.clone()), ..Default::default() }; let post = post @@ -103,9 +111,13 @@ impl Object for post::Model { href: Url::parse(&creator.id)?, kind: Default::default(), }; + let id: ObjectId = generate_object_id(data.domain())?.into(); let note = Note { kind: Default::default(), - id: generate_object_id(data.domain())?.into(), + url: id.clone().to_string(), + id, + sensitive: false, + published: chrono::Utc::now().to_rfc3339(), attributed_to: Url::parse(&data.local_user().await?.id).unwrap().into(), to: vec![public()], content: format!("Hello {}", creator.name),