diff --git a/crates/apub/assets/lemmy-comment.json b/crates/apub/assets/lemmy-comment.json index 663067ea8..1d0740ebb 100644 --- a/crates/apub/assets/lemmy-comment.json +++ b/crates/apub/assets/lemmy-comment.json @@ -19,7 +19,7 @@ "https://w3id.org/security/v1" ], "attributedTo": "https://lemmy.ml/u/nutomic", - "content": "While I very much get and respect the general sentiment, I think from the perspective of a Central European non-English person in a country with a significant number of, also non-English speaking Nazis, the current approach of filtering slurs based on an English regex is fatally flawed. You can happily use Lemmy to create a hostile far right community where everyone is easily able to use whatever hurtful slurs they want as long as they are not the few specifically blocked English ones. \n\nOn the other hand you create a situation where people feel the need to question the choice of software of their community because they read about censorship or whatever to be used in Lemmy and might stay away and move to other software even though the would maybe never be affected by the slur-filter as the number is not so large and the overlap with other languages not very big.\n\nSo I would argue that this specific implementation of a slur-filter just doesn't achieve what it aims to achieve and should be fundamentally rethought, maybe as configurable per instance.", + "summary": "While I very much get and respect the general sentiment, I think from the perspective of a Central European non-English person in a country with a significant number of, also non-English speaking Nazis, the current approach of filtering slurs based on an English regex is fatally flawed. You can happily use Lemmy to create a hostile far right community where everyone is easily able to use whatever hurtful slurs they want as long as they are not the few specifically blocked English ones. \n\nOn the other hand you create a situation where people feel the need to question the choice of software of their community because they read about censorship or whatever to be used in Lemmy and might stay away and move to other software even though the would maybe never be affected by the slur-filter as the number is not so large and the overlap with other languages not very big.\n\nSo I would argue that this specific implementation of a slur-filter just doesn't achieve what it aims to achieve and should be fundamentally rethought, maybe as configurable per instance.", "id": "https://lemmy.ml/comment/38741", "inReplyTo": "https://lemmy.ml/post/55143", "mediaType": "text/html", diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 7d5b99234..9cb56ca44 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -13,11 +13,12 @@ use activitystreams::{ unparsed::Unparsed, }; use chrono::{DateTime, FixedOffset}; +use html2md::parse_html; use lemmy_api_common::blocking; use lemmy_apub_lib::{ signatures::PublicKey, traits::{ActorType, ApubObject, FromApub, ToApub}, - values::{MediaTypeHtml, MediaTypeMarkdown}, + values::MediaTypeMarkdown, verify::verify_domains_match, }; use lemmy_db_schema::{ @@ -54,8 +55,7 @@ pub struct Person { preferred_username: String, /// displayname (can be changed at any time) name: Option, - content: Option, - media_type: Option, + summary: Option, source: Option, /// user avatar icon: Option, @@ -186,8 +186,7 @@ impl ToApub for ApubPerson { id: self.actor_id.to_owned().into_inner(), preferred_username: self.name.clone(), name: self.display_name.clone(), - content: self.bio.as_ref().map(|b| markdown_to_html(b)), - media_type: self.bio.as_ref().map(|_| MediaTypeHtml::Html), + summary: self.bio.as_ref().map(|b| markdown_to_html(b)), source, icon, image, @@ -224,7 +223,11 @@ impl FromApub for ApubPerson { let actor_id = Some(person.id(expected_domain)?.clone().into()); let name = person.preferred_username.clone(); let display_name: Option = person.name.clone(); - let bio = person.source.clone().map(|s| s.content); + let bio = if let Some(source) = &person.source { + Some(source.content.clone()) + } else { + person.summary.as_ref().map(|s| parse_html(s)) + }; let shared_inbox = person.endpoints.shared_inbox.clone().map(|s| s.into()); let bot_account = match person.kind { UserTypes::Person => false, @@ -315,8 +318,7 @@ mod tests { assert!(person.public_key.is_some()); assert!(!person.local); assert_eq!(request_counter, 0); - // TODO: pleroma uses summary for user profile, while we use content - //assert!(person.bio.is_some()); + assert_eq!(person.bio.as_ref().unwrap().len(), 873); DbPerson::delete(&*context.pool().get().unwrap(), person.id).unwrap(); } diff --git a/scripts/test.sh b/scripts/test.sh index 0a3fa90fc..9e4582497 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -9,4 +9,4 @@ export LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy # so to load the config we need to traverse to the repo root export LEMMY_CONFIG_LOCATION=../../config/config.hjson RUST_BACKTRACE=1 \ - cargo test --workspace --no-fail-fast + cargo test --workspace --no-fail-fast test_fetch_pleroma_person