feat: add pronouns to users
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/push/publish-docs Pipeline was successful

This commit is contained in:
Radical 2025-06-01 15:58:07 +02:00
parent 2f7fac8db5
commit ee8211a321
5 changed files with 32 additions and 0 deletions

View file

@ -865,6 +865,7 @@ pub struct User {
username: String,
display_name: Option<String>,
avatar: Option<String>,
pronouns: Option<String>,
}
impl User {
@ -915,6 +916,7 @@ pub struct Me {
username: String,
display_name: Option<String>,
avatar: Option<String>,
pronouns: Option<String>,
email: String,
pub email_verified: bool,
}
@ -1090,6 +1092,25 @@ impl Me {
Ok(())
}
pub async fn set_pronouns(&mut self, data: &Data, new_pronouns: String) -> Result<(), Error> {
let mut conn = data.pool.get().await?;
use users::dsl;
update(users::table)
.filter(dsl::uuid.eq(self.uuid))
.set((
dsl::pronouns.eq(new_pronouns.as_str()),
))
.execute(&mut conn)
.await?;
if data.get_cache_key(self.uuid.to_string()).await.is_ok() {
data.del_cache_key(self.uuid.to_string()).await?
}
Ok(())
}
}
#[derive(Deserialize)]