summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2022-07-25 02:26:35 +0200
committerpennae <github@quasiparticle.net>2022-07-25 02:45:55 +0200
commit9e6572fa282a18fecfb31a2c35c17c0e8c23e371 (patch)
treec4ead0f54601fe010e2e17b0a8b43f6362b1c1a4 /src/db
parent9aacaaf079373f8bc25f0533d7f6218e691c5de7 (diff)
downloadminor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.tar.gz
minor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.tar.xz
minor-skulk-9e6572fa282a18fecfb31a2c35c17c0e8c23e371.zip
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.
Diffstat (limited to 'src/db')
-rw-r--r--src/db/mod.rs8
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?;