From 1c6f74cad524c5ab49201d19df8c671761a1ddff Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Tue, 2 Nov 2021 12:49:28 +0100 Subject: [PATCH] Convert note.content and chat_message.content to html (fixes #1871) --- crates/apub/assets/lemmy/objects/chat_message.json | 2 +- crates/apub/assets/lemmy/objects/note.json | 2 +- crates/apub/src/objects/comment.rs | 3 ++- crates/apub/src/objects/private_message.rs | 7 +++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/apub/assets/lemmy/objects/chat_message.json b/crates/apub/assets/lemmy/objects/chat_message.json index 45790231d..c639aef92 100644 --- a/crates/apub/assets/lemmy/objects/chat_message.json +++ b/crates/apub/assets/lemmy/objects/chat_message.json @@ -5,7 +5,7 @@ "to": [ "https://queer.hacktivis.me/users/lanodan" ], - "content": "Hello hello, testing", + "content": "

Hello hello, testing

\n", "mediaType": "text/html", "source": { "content": "Hello hello, testing", diff --git a/crates/apub/assets/lemmy/objects/note.json b/crates/apub/assets/lemmy/objects/note.json index 2a20be29d..c353d0b2b 100644 --- a/crates/apub/assets/lemmy/objects/note.json +++ b/crates/apub/assets/lemmy/objects/note.json @@ -4,7 +4,7 @@ "attributedTo": "https://enterprise.lemmy.ml/u/picard", "to": ["https://www.w3.org/ns/activitystreams#Public"], "inReplyTo": "https://enterprise.lemmy.ml/post/55143", - "content": "first comment!", + "content": "

first comment!

\n", "mediaType": "text/html", "source": { "content": "first comment!", diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index b5f72ca38..3e3d10df3 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -38,6 +38,7 @@ use crate::{ }, PostOrComment, }; +use lemmy_utils::utils::markdown_to_html; #[derive(Clone, Debug)] pub struct ApubComment(Comment); @@ -106,7 +107,7 @@ impl ApubObject for ApubComment { id: self.ap_id.to_owned().into_inner(), attributed_to: ObjectId::new(creator.actor_id), to: vec![public()], - content: self.content.clone(), + content: markdown_to_html(&self.content), media_type: Some(MediaTypeHtml::Html), source: SourceCompat::Lemmy(Source { content: self.content.clone(), diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index 678435eeb..81615fdc9 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -19,7 +19,10 @@ use lemmy_db_schema::{ }, traits::Crud, }; -use lemmy_utils::{utils::convert_datetime, LemmyError}; +use lemmy_utils::{ + utils::{convert_datetime, markdown_to_html}, + LemmyError, +}; use lemmy_websocket::LemmyContext; use std::ops::Deref; use url::Url; @@ -81,7 +84,7 @@ impl ApubObject for ApubPrivateMessage { id: self.ap_id.clone().into(), attributed_to: ObjectId::new(creator.actor_id), to: [ObjectId::new(recipient.actor_id)], - content: self.content.clone(), + content: markdown_to_html(&self.content), media_type: Some(MediaTypeHtml::Html), source: Some(Source { content: self.content.clone(),