From fa859f616ab131d3f0e75609b9d2508cb3ddab3e Mon Sep 17 00:00:00 2001 From: kozabrada123 Date: Sun, 18 Aug 2024 14:45:12 +0200 Subject: [PATCH] fix a deserialization error on Spacebar See spacebarchat/server#1188 A deserialization error was happening with get_user_profile, where pronouns should have been serialized as an empty string, but were instead serialized as null. --- src/types/entities/user.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/types/entities/user.rs b/src/types/entities/user.rs index 0ce4c9d..9646cc1 100644 --- a/src/types/entities/user.rs +++ b/src/types/entities/user.rs @@ -6,7 +6,7 @@ use crate::errors::ChorusError; use crate::types::utils::Snowflake; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; -use serde_aux::prelude::deserialize_option_number_from_string; +use serde_aux::prelude::{deserialize_option_number_from_string, deserialize_default_from_null}; use serde_repr::{Deserialize_repr, Serialize_repr}; use std::array::TryFromSliceError; use std::fmt::Debug; @@ -257,6 +257,9 @@ pub struct UserProfileMetadata { /// The guild ID this profile applies to, if it is a guild profile. pub guild_id: Option, /// The user's pronouns, up to 40 characters + #[serde(deserialize_with = "deserialize_default_from_null")] + // Note: spacebar will send this is as null, while it should be "" + // See issue 1188 pub pronouns: String, /// The user's bio / description, up to 190 characters pub bio: Option,