mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 14:48:19 +01:00
Add url, published, and sensitive fields to Note struct in post.rs
This commit is contained in:
parent
7266790889
commit
19291bc107
|
|
@ -39,6 +39,9 @@ pub struct Note {
|
||||||
content: String,
|
content: String,
|
||||||
in_reply_to: Option<ObjectId<post::Model>>,
|
in_reply_to: Option<ObjectId<post::Model>>,
|
||||||
tag: Vec<Mention>,
|
tag: Vec<Mention>,
|
||||||
|
url: String,
|
||||||
|
published: String,
|
||||||
|
sensitive: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
|
@ -84,7 +87,12 @@ impl Object for post::Model {
|
||||||
content: Set(json.content.clone()),
|
content: Set(json.content.clone()),
|
||||||
id: Set(json.id.to_string()),
|
id: Set(json.id.to_string()),
|
||||||
creator: Set(creator.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),
|
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()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let post = post
|
let post = post
|
||||||
|
|
@ -103,9 +111,13 @@ impl Object for post::Model {
|
||||||
href: Url::parse(&creator.id)?,
|
href: Url::parse(&creator.id)?,
|
||||||
kind: Default::default(),
|
kind: Default::default(),
|
||||||
};
|
};
|
||||||
|
let id: ObjectId<post::Model> = generate_object_id(data.domain())?.into();
|
||||||
let note = Note {
|
let note = Note {
|
||||||
kind: Default::default(),
|
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(),
|
attributed_to: Url::parse(&data.local_user().await?.id).unwrap().into(),
|
||||||
to: vec![public()],
|
to: vec![public()],
|
||||||
content: format!("Hello {}", creator.name),
|
content: format!("Hello {}", creator.name),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue