]> Untitled Git - lemmy.git/commitdiff
Filter empty username strings from Mastodon (fixes #2886) (#2887)
authorNutomic <me@nutomic.com>
Mon, 5 Jun 2023 11:56:53 +0000 (13:56 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Jun 2023 11:56:53 +0000 (13:56 +0200)
* Filter empty username strings from Mastodon (fixes #2886)

* add issue link

crates/apub/src/objects/person.rs

index e5431d141b084007e88e50a9e78c6824897d7343..d3422b063faae81c812aba8cd401fc12169fffa1 100644 (file)
@@ -144,9 +144,13 @@ impl Object for ApubPerson {
   ) -> Result<ApubPerson, LemmyError> {
     let instance_id = fetch_instance_actor_for_object(&person.id, context).await?;
 
+    // Some Mastodon users have `name: ""` (empty string), need to convert that to `None`
+    // https://github.com/mastodon/mastodon/issues/25233
+    let display_name = person.name.filter(|n| !n.is_empty());
+
     let person_form = PersonInsertForm {
       name: person.preferred_username,
-      display_name: person.name,
+      display_name,
       banned: None,
       ban_expires: None,
       deleted: Some(false),