Skip to content

Commit

Permalink
fix a deserialization error on Spacebar
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kozabrada123 committed Aug 18, 2024
1 parent 28e3f21 commit fa859f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/types/entities/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -257,6 +257,9 @@ pub struct UserProfileMetadata {
/// The guild ID this profile applies to, if it is a guild profile.
pub guild_id: Option<Snowflake>,
/// 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<String>,
Expand Down

0 comments on commit fa859f6

Please sign in to comment.