mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 14:21:19 +00:00
Also change group.content to summary
This commit is contained in:
parent
c4ade96ef4
commit
e14e0c3cae
7 changed files with 24 additions and 21 deletions
|
@ -19,7 +19,7 @@
|
||||||
"https://w3id.org/security/v1"
|
"https://w3id.org/security/v1"
|
||||||
],
|
],
|
||||||
"attributedTo": "https://lemmy.ml/u/nutomic",
|
"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",
|
"id": "https://lemmy.ml/comment/38741",
|
||||||
"inReplyTo": "https://lemmy.ml/post/55143",
|
"inReplyTo": "https://lemmy.ml/post/55143",
|
||||||
"mediaType": "text/html",
|
"mediaType": "text/html",
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
"https://w3id.org/security/v1"
|
"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": {
|
"endpoints": {
|
||||||
"sharedInbox": "https://lemmy.ml/inbox"
|
"sharedInbox": "https://lemmy.ml/inbox"
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,6 @@
|
||||||
},
|
},
|
||||||
"id": "https://lemmy.ml/c/announcements",
|
"id": "https://lemmy.ml/c/announcements",
|
||||||
"inbox": "https://lemmy.ml/c/announcements/inbox",
|
"inbox": "https://lemmy.ml/c/announcements/inbox",
|
||||||
"mediaType": "text/html",
|
|
||||||
"moderators": "https://lemmy.ml/c/announcements/moderators",
|
"moderators": "https://lemmy.ml/c/announcements/moderators",
|
||||||
"name": "Announcements",
|
"name": "Announcements",
|
||||||
"outbox": "https://lemmy.ml/c/announcements/outbox",
|
"outbox": "https://lemmy.ml/c/announcements/outbox",
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
},
|
},
|
||||||
"https://w3id.org/security/v1"
|
"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": {
|
"endpoints": {
|
||||||
"sharedInbox": "https://lemmy.ml/inbox"
|
"sharedInbox": "https://lemmy.ml/inbox"
|
||||||
},
|
},
|
||||||
|
@ -28,7 +28,6 @@
|
||||||
},
|
},
|
||||||
"id": "https://lemmy.ml/u/nutomic",
|
"id": "https://lemmy.ml/u/nutomic",
|
||||||
"inbox": "https://lemmy.ml/u/nutomic/inbox",
|
"inbox": "https://lemmy.ml/u/nutomic/inbox",
|
||||||
"mediaType": "text/html",
|
|
||||||
"outbox": "https://lemmy.ml/u/nutomic/outbox",
|
"outbox": "https://lemmy.ml/u/nutomic/outbox",
|
||||||
"preferredUsername": "nutomic",
|
"preferredUsername": "nutomic",
|
||||||
"publicKey": {
|
"publicKey": {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
fetcher::community::{fetch_community_outbox, update_community_mods},
|
fetcher::community::{fetch_community_outbox, update_community_mods},
|
||||||
generate_moderators_url,
|
generate_moderators_url,
|
||||||
generate_outbox_url,
|
generate_outbox_url,
|
||||||
objects::{create_tombstone, ImageObject, Source},
|
objects::{create_tombstone, get_summary_from_string_or_source, ImageObject, Source},
|
||||||
CommunityType,
|
CommunityType,
|
||||||
};
|
};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
|
@ -21,7 +21,7 @@ use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{
|
||||||
signatures::PublicKey,
|
signatures::PublicKey,
|
||||||
traits::{ActorType, ApubObject, FromApub, ToApub},
|
traits::{ActorType, ApubObject, FromApub, ToApub},
|
||||||
values::{MediaTypeHtml, MediaTypeMarkdown},
|
values::MediaTypeMarkdown,
|
||||||
verify::verify_domains_match,
|
verify::verify_domains_match,
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
|
@ -55,8 +55,7 @@ pub struct Group {
|
||||||
preferred_username: String,
|
preferred_username: String,
|
||||||
/// title (can be changed at any time)
|
/// title (can be changed at any time)
|
||||||
name: String,
|
name: String,
|
||||||
content: Option<String>,
|
summary: Option<String>,
|
||||||
media_type: Option<MediaTypeHtml>,
|
|
||||||
source: Option<Source>,
|
source: Option<Source>,
|
||||||
icon: Option<ImageObject>,
|
icon: Option<ImageObject>,
|
||||||
/// banner
|
/// banner
|
||||||
|
@ -89,7 +88,7 @@ impl Group {
|
||||||
let actor_id = Some(group.id(expected_domain)?.clone().into());
|
let actor_id = Some(group.id(expected_domain)?.clone().into());
|
||||||
let name = group.preferred_username.clone();
|
let name = group.preferred_username.clone();
|
||||||
let title = group.name.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 shared_inbox = group.endpoints.shared_inbox.clone().map(|s| s.into());
|
||||||
|
|
||||||
let slur_regex = &settings.slur_regex();
|
let slur_regex = &settings.slur_regex();
|
||||||
|
@ -218,8 +217,7 @@ impl ToApub for ApubCommunity {
|
||||||
id: self.actor_id(),
|
id: self.actor_id(),
|
||||||
preferred_username: self.name.clone(),
|
preferred_username: self.name.clone(),
|
||||||
name: self.title.clone(),
|
name: self.title.clone(),
|
||||||
content: self.description.as_ref().map(|b| markdown_to_html(b)),
|
summary: self.description.as_ref().map(|b| markdown_to_html(b)),
|
||||||
media_type: self.description.as_ref().map(|_| MediaTypeHtml::Html),
|
|
||||||
source,
|
source,
|
||||||
icon,
|
icon,
|
||||||
image,
|
image,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use activitystreams::{
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
|
use html2md::parse_html;
|
||||||
use lemmy_apub_lib::values::MediaTypeMarkdown;
|
use lemmy_apub_lib::values::MediaTypeMarkdown;
|
||||||
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
||||||
use serde::{Deserialize, Serialize};
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
check_is_apub_id_valid,
|
check_is_apub_id_valid,
|
||||||
context::lemmy_context,
|
context::lemmy_context,
|
||||||
generate_outbox_url,
|
generate_outbox_url,
|
||||||
objects::{ImageObject, Source},
|
objects::{get_summary_from_string_or_source, ImageObject, Source},
|
||||||
};
|
};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
actor::Endpoints,
|
actor::Endpoints,
|
||||||
|
@ -13,7 +13,6 @@ use activitystreams::{
|
||||||
unparsed::Unparsed,
|
unparsed::Unparsed,
|
||||||
};
|
};
|
||||||
use chrono::{DateTime, FixedOffset};
|
use chrono::{DateTime, FixedOffset};
|
||||||
use html2md::parse_html;
|
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{
|
||||||
signatures::PublicKey,
|
signatures::PublicKey,
|
||||||
|
@ -223,11 +222,7 @@ impl FromApub for ApubPerson {
|
||||||
let actor_id = Some(person.id(expected_domain)?.clone().into());
|
let actor_id = Some(person.id(expected_domain)?.clone().into());
|
||||||
let name = person.preferred_username.clone();
|
let name = person.preferred_username.clone();
|
||||||
let display_name: Option<String> = person.name.clone();
|
let display_name: Option<String> = person.name.clone();
|
||||||
let bio = if let Some(source) = &person.source {
|
let bio = get_summary_from_string_or_source(&person.summary, &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 shared_inbox = person.endpoints.shared_inbox.clone().map(|s| s.into());
|
||||||
let bot_account = match person.kind {
|
let bot_account = match person.kind {
|
||||||
UserTypes::Person => false,
|
UserTypes::Person => false,
|
||||||
|
@ -293,7 +288,7 @@ mod tests {
|
||||||
assert_eq!(person.name, "nutomic");
|
assert_eq!(person.name, "nutomic");
|
||||||
assert!(person.public_key.is_some());
|
assert!(person.public_key.is_some());
|
||||||
assert!(!person.local);
|
assert!(!person.local);
|
||||||
assert!(person.bio.is_some());
|
assert_eq!(person.bio.as_ref().unwrap().len(), 77);
|
||||||
assert_eq!(request_counter, 0);
|
assert_eq!(request_counter, 0);
|
||||||
|
|
||||||
let to_apub = person.to_apub(context.pool()).await.unwrap();
|
let to_apub = person.to_apub(context.pool()).await.unwrap();
|
||||||
|
|
|
@ -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
|
# so to load the config we need to traverse to the repo root
|
||||||
export LEMMY_CONFIG_LOCATION=../../config/config.hjson
|
export LEMMY_CONFIG_LOCATION=../../config/config.hjson
|
||||||
RUST_BACKTRACE=1 \
|
RUST_BACKTRACE=1 \
|
||||||
cargo test --workspace --no-fail-fast test_fetch_pleroma_person
|
cargo test --workspace --no-fail-fast
|
||||||
|
|
Loading…
Reference in a new issue