diff options
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/mod.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index 6cea895..d9a114e 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,7 +1,6 @@ use std::{error::Error, mem::replace, sync::Arc}; use anyhow::Result; -use chrono::{DateTime, Duration, Utc}; use password_hash::SaltString; use rocket::{ fairing::{self, Fairing}, @@ -12,6 +11,7 @@ use rocket::{ }; use serde_json::Value; use sqlx::{query, query_as, query_scalar, PgPool, Postgres, Transaction}; +use time::{Duration, OffsetDateTime}; use crate::{ crypto::WrappedKeyBundle, @@ -198,7 +198,7 @@ impl DbConn { key: HawkKey, verified: bool, verify_code: Option<&str>, - ) -> sqlx::Result<DateTime<Utc>> { + ) -> sqlx::Result<OffsetDateTime> { query_scalar!( r#"insert into user_session (session_id, user_id, req_hmac_key, device_id, verified, verify_code) @@ -313,7 +313,7 @@ impl DbConn { payload: &Value, ttl: u32, ) -> sqlx::Result<i64> { - let expires = Utc::now() + Duration::seconds(ttl as i64); + let expires = OffsetDateTime::now_utc() + Duration::seconds(ttl as i64); query!( r#"insert into device_commands (device_id, command, payload, expires, sender) values ($1, $2, $3, $4, $5) @@ -989,7 +989,7 @@ impl DbConn { // // - pub async fn add_invite_code(&self, code: &str, expires: DateTime<Utc>) -> sqlx::Result<()> { + pub async fn add_invite_code(&self, code: &str, expires: OffsetDateTime) -> sqlx::Result<()> { query!(r#"insert into invite_codes (code, expires_at) values ($1, $2)"#, code, expires,) .execute(&mut self.get().await?.tx) .await?; |