Lines
72.73 %
Functions
100 %
Branches
//! The user's zone, which report dates are read in.
use server::command::CmdResult;
use server::command::config::GetTimezone;
use server::timezone::Tz;
use uuid::Uuid;
use super::Failure;
const CTX: &str = "report";
/// The zone of `user_id`'s reports; UTC when they set none.
///
/// # Errors
/// A refusal when the stored value is not a zone, an internal failure otherwise.
pub async fn user_zone(user_id: Uuid) -> Result<Tz, Failure> {
match GetTimezone::new()
.user_id(user_id)
.run()
.await
.map_err(|err| Failure::from_command(CTX, err))?
{
Some(CmdResult::Timezone(zone)) => Ok(zone),
_ => Err(Failure::Internal(wasmtime::Error::msg(
"get-timezone: unexpected result",
))),
}