1
0
Fork 0
forked from alemi/upub

feat: parse markdown when posting

can't be toggled off for now 🤷
This commit is contained in:
əlemi 2024-05-02 16:29:01 +02:00
parent 505bdfa234
commit 34df958af0
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 8 additions and 0 deletions

1
Cargo.lock generated
View file

@ -4412,6 +4412,7 @@ dependencies = [
"futures",
"jrd",
"mastodon-async-entities",
"mdhtml",
"nodeinfo",
"openssl",
"rand",

View file

@ -24,6 +24,7 @@ chrono = { version = "0.4", features = ["serde"] }
uuid = { version = "1.8", features = ["v4"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
mdhtml = { path = "mdhtml", features = ["markdown"] }
jrd = "0.1"
tracing = "0.1"
tracing-subscriber = "0.3"

View file

@ -23,6 +23,9 @@ impl apb::server::Outbox for Context {
.set_attributed_to(Node::link(uid.clone()))
.set_published(Some(chrono::Utc::now()))
)?;
if let Some(content) = object_model.content {
object_model.content = Some(mdhtml::safe_markdown(&content));
}
match (&object_model.in_reply_to, &object_model.context) {
(Some(reply_id), None) => // get context from replied object
object_model.context = self.fetch_object(reply_id).await?.context,
@ -84,6 +87,9 @@ impl apb::server::Outbox for Context {
object_model.bto = activity_model.bto.clone();
object_model.cc = activity_model.cc.clone();
object_model.bcc = activity_model.bcc.clone();
if let Some(content) = object_model.content {
object_model.content = Some(mdhtml::safe_markdown(&content));
}
match (&object_model.in_reply_to, &object_model.context) {
(Some(reply_id), None) => // get context from replied object
object_model.context = self.fetch_object(reply_id).await?.context,