diff --git a/crates/core/database/src/models/users/model.rs b/crates/core/database/src/models/users/model.rs index 1e49e022b..5505812a9 100644 --- a/crates/core/database/src/models/users/model.rs +++ b/crates/core/database/src/models/users/model.rs @@ -44,6 +44,10 @@ auto_derived_partial!( /// Bot information #[serde(skip_serializing_if = "Option::is_none")] pub bot: Option, + + // User's displayed pronouns + #[serde(skip_serializing_if = "Option::is_none")] + pub pronouns: Option>, }, "PartialUser" ); @@ -114,6 +118,7 @@ auto_derived!( StatusPresence, ProfileContent, ProfileBackground, + Pronouns, } ); @@ -180,6 +185,7 @@ impl User { x.background = None; } } + FieldsUser::Pronouns => self.pronouns = None, } } @@ -198,6 +204,7 @@ impl User { FieldsUser::StatusPresence, FieldsUser::ProfileContent, FieldsUser::ProfileBackground, + FieldsUser::Pronouns, ], ) .await diff --git a/crates/core/database/src/models/users/ops/mongodb.rs b/crates/core/database/src/models/users/ops/mongodb.rs index 6bea50779..5657be172 100644 --- a/crates/core/database/src/models/users/ops/mongodb.rs +++ b/crates/core/database/src/models/users/ops/mongodb.rs @@ -295,6 +295,7 @@ impl IntoDocumentPath for FieldsUser { FieldsUser::ProfileContent => "profile.content", FieldsUser::StatusPresence => "status.presence", FieldsUser::StatusText => "status.text", + FieldsUser::Pronouns => "pronouns", }) } } diff --git a/crates/core/database/src/util/bridge/v0.rs b/crates/core/database/src/util/bridge/v0.rs index 45fad9035..71ee36e2b 100644 --- a/crates/core/database/src/util/bridge/v0.rs +++ b/crates/core/database/src/util/bridge/v0.rs @@ -270,6 +270,9 @@ impl crate::User { relationship, online: can_see_profile && revolt_presence::is_online(&self.id).await, id: self.id, + pronouns: self + .pronouns + .map(|pronouns| pronouns.iter().map(|pronoun| pronoun.to_owned()).collect()), } } } diff --git a/crates/core/models/src/v0/users.rs b/crates/core/models/src/v0/users.rs index 9652cd737..2e69b3e6e 100644 --- a/crates/core/models/src/v0/users.rs +++ b/crates/core/models/src/v0/users.rs @@ -40,6 +40,9 @@ auto_derived!( #[serde(skip_serializing_if = "Option::is_none")] pub bot: Option, + // User's displayed pronouns + #[serde(skip_serializing_if = "Option::is_none")] + pub pronouns: Option>, /// Current session user's relationship with this user pub relationship: RelationshipStatus, /// Whether this user is currently online diff --git a/crates/delta/src/routes/users/edit_user.rs b/crates/delta/src/routes/users/edit_user.rs index c1c2ba905..d2979a103 100644 --- a/crates/delta/src/routes/users/edit_user.rs +++ b/crates/delta/src/routes/users/edit_user.rs @@ -52,6 +52,11 @@ pub struct DataEditUser { /// Fields to remove from user object #[validate(length(min = 1))] remove: Option>, + + // User's displayed pronouns + #[cfg_attr(feature = "validator", validate(length(min = 1, max = 5)))] + #[serde(skip_serializing_if = "Option::is_none")] + pub pronouns: Option>, } /// # Edit User @@ -96,6 +101,7 @@ pub async fn req( && data.badges.is_none() && data.flags.is_none() && data.remove.is_none() + && data.pronouns.is_none() { return Ok(Json(user)); } @@ -125,6 +131,7 @@ pub async fn req( display_name: data.display_name, badges: data.badges, flags: data.flags, + pronouns: data.pronouns, ..Default::default() }; diff --git a/crates/quark/src/impl/generic/users/user.rs b/crates/quark/src/impl/generic/users/user.rs index 38609b0f7..bba94bd3c 100644 --- a/crates/quark/src/impl/generic/users/user.rs +++ b/crates/quark/src/impl/generic/users/user.rs @@ -71,6 +71,7 @@ impl User { } } FieldsUser::DisplayName => self.display_name = None, + FieldsUser::Pronouns => self.pronouns = None, } } diff --git a/crates/quark/src/impl/mongo/users/user.rs b/crates/quark/src/impl/mongo/users/user.rs index bd1bb3291..4fb1ce00d 100644 --- a/crates/quark/src/impl/mongo/users/user.rs +++ b/crates/quark/src/impl/mongo/users/user.rs @@ -338,6 +338,7 @@ impl IntoDocumentPath for FieldsUser { FieldsUser::StatusPresence => "status.presence", FieldsUser::StatusText => "status.text", FieldsUser::DisplayName => "display_name", + FieldsUser::Pronouns => "pronouns", }) } } diff --git a/crates/quark/src/models/users/user.rs b/crates/quark/src/models/users/user.rs index 6c5e2c801..07dad1c84 100644 --- a/crates/quark/src/models/users/user.rs +++ b/crates/quark/src/models/users/user.rs @@ -167,6 +167,11 @@ pub struct User { /// Whether this user is currently online #[serde(skip_serializing_if = "Option::is_none")] pub online: Option, + + // User's displayed pronouns + #[cfg_attr(feature = "validator", validate(length(min = 1, max = 5)))] + #[serde(skip_serializing_if = "Option::is_none")] + pub pronouns: Option>, } /// Optional fields on user object @@ -178,6 +183,7 @@ pub enum FieldsUser { ProfileContent, ProfileBackground, DisplayName, + Pronouns, } /// Enumeration providing a hint to the type of user we are handling