]> Untitled Git - lemmy.git/commitdiff
Convert HTML from titles into markdown (#2709)
authorKradyz <81911574+Kradyz@users.noreply.github.com>
Tue, 7 Feb 2023 02:27:17 +0000 (03:27 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2023 02:27:17 +0000 (03:27 +0100)
Co-authored-by: Kradyz <k@radiz.nl>
crates/apub/src/objects/post.rs

index 33794344e718122168929f0a94fddfe56f592f58..e7a1d475d5abc3b3fc38ed3d38da3acb808dc66b 100644 (file)
@@ -23,6 +23,7 @@ use activitypub_federation::{
 use activitystreams_kinds::public;
 use anyhow::anyhow;
 use chrono::NaiveDateTime;
+use html2md::parse_html;
 use lemmy_api_common::{
   context::LemmyContext,
   request::fetch_site_data,
@@ -183,7 +184,8 @@ impl ApubObject for ApubPost {
         page
           .content
           .clone()
-          .and_then(|c| c.lines().next().map(ToString::to_string))
+          .as_ref()
+          .and_then(|c| parse_html(c).lines().next().map(ToString::to_string))
       })
       .ok_or_else(|| anyhow!("Object must have name or content"))?;
     if name.chars().count() > MAX_TITLE_LENGTH {