From 9e6572fa282a18fecfb31a2c35c17c0e8c23e371 Mon Sep 17 00:00:00 2001 From: pennae Date: Mon, 25 Jul 2022 02:26:35 +0200 Subject: remove dependency on chrono prompted by a cargo audit run. time works just as well and is better maintained. web-push still uses chrono, but from the looks of things it won't be affected. --- src/db/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/db') 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> { + ) -> sqlx::Result { 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 { - 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) -> 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?; -- cgit v1.2.3