From 7248c4a6f46f0573b9060625fca3e7c5526b8c3e Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 5 Jun 2023 13:56:53 +0200 Subject: [PATCH] Filter empty username strings from Mastodon (fixes #2886) (#2887) * Filter empty username strings from Mastodon (fixes #2886) * add issue link --- crates/apub/src/objects/person.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index e5431d141..d3422b063 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -144,9 +144,13 @@ impl Object for ApubPerson { ) -> Result { 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),