feat: add pronouns to users
This commit is contained in:
parent
2f7fac8db5
commit
ee8211a321
5 changed files with 32 additions and 0 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue