users: store timezone, default is "UTC"

This commit is contained in:
Philippe Loctaux 2023-04-13 22:01:27 +02:00
parent 1168e1494c
commit e49c146dfd
14 changed files with 415 additions and 322 deletions

View file

@ -16,6 +16,7 @@ pub struct Users {
pub password_recover: Option<String>,
pub paper_key: Option<String>,
pub is_archived: bool,
pub timezone: String,
}
impl Users {
@ -163,4 +164,18 @@ impl Users {
Ok((query.rows_affected() == 1).then_some(()))
}
pub async fn set_timezone(
conn: impl SqliteExecutor<'_>,
id: &str,
timezone: &str,
) -> Result<Option<()>, Error> {
let query: SqliteQueryResult =
sqlx::query_file!("queries/users/set_timezone.sql", timezone, id)
.execute(conn)
.await
.map_err(handle_error)?;
Ok((query.rows_affected() == 1).then_some(()))
}
}