Also change group.content to summary

This commit is contained in:
Felix Ableitner 2021-10-22 13:11:58 +02:00
parent c4ade96ef4
commit e14e0c3cae
7 changed files with 24 additions and 21 deletions

View file

@ -19,7 +19,7 @@
"https://w3id.org/security/v1"
],
"attributedTo": "https://lemmy.ml/u/nutomic",
"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.",
"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.",
"id": "https://lemmy.ml/comment/38741",
"inReplyTo": "https://lemmy.ml/post/55143",
"mediaType": "text/html",

View file

@ -18,7 +18,7 @@
},
"https://w3id.org/security/v1"
],
"content": "<p>Lemmy Announcements</p>\n<hr />\n<p>Feel free to announce new communities here.</p>\n<p>Other than that, this is <em>reserved for admin use only</em>.</p>\n",
"summary": "<p>Lemmy Announcements</p>\n<hr />\n<p>Feel free to announce new communities here.</p>\n<p>Other than that, this is <em>reserved for admin use only</em>.</p>\n",
"endpoints": {
"sharedInbox": "https://lemmy.ml/inbox"
},
@ -29,7 +29,6 @@
},
"id": "https://lemmy.ml/c/announcements",
"inbox": "https://lemmy.ml/c/announcements/inbox",
"mediaType": "text/html",
"moderators": "https://lemmy.ml/c/announcements/moderators",
"name": "Announcements",
"outbox": "https://lemmy.ml/c/announcements/outbox",

View file

@ -18,7 +18,7 @@
},
"https://w3id.org/security/v1"
],
"content": "<p>Lemmy maintainer. Interested in politics, video games, and many other things.</p>\n",
"summary": "<p>Lemmy maintainer. Interested in politics, video games, and many other things.</p>\n",
"endpoints": {
"sharedInbox": "https://lemmy.ml/inbox"
},
@ -28,7 +28,6 @@
},
"id": "https://lemmy.ml/u/nutomic",
"inbox": "https://lemmy.ml/u/nutomic/inbox",
"mediaType": "text/html",
"outbox": "https://lemmy.ml/u/nutomic/outbox",
"preferredUsername": "nutomic",
"publicKey": {

View file

@ -4,7 +4,7 @@ use crate::{
fetcher::community::{fetch_community_outbox, update_community_mods},
generate_moderators_url,
generate_outbox_url,
objects::{create_tombstone, ImageObject, Source},
objects::{create_tombstone, get_summary_from_string_or_source, ImageObject, Source},
CommunityType,
};
use activitystreams::{
@ -21,7 +21,7 @@ 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::{
@ -55,8 +55,7 @@ pub struct Group {
preferred_username: String,
/// title (can be changed at any time)
name: String,
content: Option<String>,
media_type: Option<MediaTypeHtml>,
summary: Option<String>,
source: Option<Source>,
icon: Option<ImageObject>,
/// banner
@ -89,7 +88,7 @@ impl Group {
let actor_id = Some(group.id(expected_domain)?.clone().into());
let name = group.preferred_username.clone();
let title = group.name.clone();
let description = group.source.clone().map(|s| s.content);
let description = get_summary_from_string_or_source(&group.summary, &group.source);
let shared_inbox = group.endpoints.shared_inbox.clone().map(|s| s.into());
let slur_regex = &settings.slur_regex();
@ -218,8 +217,7 @@ impl ToApub for ApubCommunity {
id: self.actor_id(),
preferred_username: self.name.clone(),
name: self.title.clone(),
content: self.description.as_ref().map(|b| markdown_to_html(b)),
media_type: self.description.as_ref().map(|_| MediaTypeHtml::Html),
summary: self.description.as_ref().map(|b| markdown_to_html(b)),
source,
icon,
image,

View file

@ -4,6 +4,7 @@ use activitystreams::{
};
use anyhow::anyhow;
use chrono::NaiveDateTime;
use html2md::parse_html;
use lemmy_apub_lib::values::MediaTypeMarkdown;
use lemmy_utils::{utils::convert_datetime, LemmyError};
use serde::{Deserialize, Serialize};
@ -55,6 +56,17 @@ where
}
}
fn get_summary_from_string_or_source(
raw: &Option<String>,
source: &Option<Source>,
) -> Option<String> {
if let Some(source) = &source {
Some(source.content.clone())
} else {
raw.as_ref().map(|s| parse_html(s))
}
}
#[cfg(test)]
mod tests {
use super::*;

View file

@ -2,7 +2,7 @@ use crate::{
check_is_apub_id_valid,
context::lemmy_context,
generate_outbox_url,
objects::{ImageObject, Source},
objects::{get_summary_from_string_or_source, ImageObject, Source},
};
use activitystreams::{
actor::Endpoints,
@ -13,7 +13,6 @@ use activitystreams::{
unparsed::Unparsed,
};
use chrono::{DateTime, FixedOffset};
use html2md::parse_html;
use lemmy_api_common::blocking;
use lemmy_apub_lib::{
signatures::PublicKey,
@ -223,11 +222,7 @@ impl FromApub for ApubPerson {
let actor_id = Some(person.id(expected_domain)?.clone().into());
let name = person.preferred_username.clone();
let display_name: Option<String> = person.name.clone();
let bio = if let Some(source) = &person.source {
Some(source.content.clone())
} else {
person.summary.as_ref().map(|s| parse_html(s))
};
let bio = get_summary_from_string_or_source(&person.summary, &person.source);
let shared_inbox = person.endpoints.shared_inbox.clone().map(|s| s.into());
let bot_account = match person.kind {
UserTypes::Person => false,
@ -293,7 +288,7 @@ mod tests {
assert_eq!(person.name, "nutomic");
assert!(person.public_key.is_some());
assert!(!person.local);
assert!(person.bio.is_some());
assert_eq!(person.bio.as_ref().unwrap().len(), 77);
assert_eq!(request_counter, 0);
let to_apub = person.to_apub(context.pool()).await.unwrap();

View file

@ -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 test_fetch_pleroma_person
cargo test --workspace --no-fail-fast