fix(ap): wrap outbound Note content in HTML paragraph tags
This commit is contained in:
@@ -28,6 +28,24 @@ use crate::{
|
||||
webfinger::webfinger_handler,
|
||||
};
|
||||
|
||||
fn content_to_html(text: &str) -> String {
|
||||
let escaped = text
|
||||
.replace('&', "&")
|
||||
.replace('<', "<")
|
||||
.replace('>', ">")
|
||||
.replace('"', """);
|
||||
let paragraphs: Vec<&str> = escaped.split('\n').filter(|s| !s.is_empty()).collect();
|
||||
if paragraphs.is_empty() {
|
||||
format!("<p>{}</p>", escaped)
|
||||
} else {
|
||||
paragraphs
|
||||
.iter()
|
||||
.map(|p| format!("<p>{}</p>", p))
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
}
|
||||
}
|
||||
|
||||
fn thought_note_json(
|
||||
thought: &domain::models::thought::Thought,
|
||||
local_actor: &crate::actors::DbActor,
|
||||
@@ -56,7 +74,7 @@ fn thought_note_json(
|
||||
"id": ap_id.to_string(),
|
||||
"url": ap_id.to_string(),
|
||||
"attributedTo": local_actor.ap_id.to_string(),
|
||||
"content": thought.content.as_str(),
|
||||
"content": content_to_html(thought.content.as_str()),
|
||||
"published": thought.created_at.to_rfc3339(),
|
||||
"to": to,
|
||||
"cc": cc,
|
||||
|
||||
Reference in New Issue
Block a user