+ Adding serialize to db::Invite type
* Invite initialization using shorthand notation now
This commit is contained in:
parent
ba5db17706
commit
2cb2d2b29e
@ -2,6 +2,8 @@ use mysql_async::{params, Pool, Conn};
|
|||||||
use mysql_async::prelude::Queryable;
|
use mysql_async::prelude::Queryable;
|
||||||
use mysql_async::error::Error as SqlError;
|
use mysql_async::error::Error as SqlError;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
use crate::{UBigInt, BigInt};
|
use crate::{UBigInt, BigInt};
|
||||||
@ -9,6 +11,7 @@ use crate::common::FromDB;
|
|||||||
use crate::{Response, no_conn};
|
use crate::{Response, no_conn};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
#[derive(Serialize)]
|
||||||
pub struct Invite {
|
pub struct Invite {
|
||||||
pub id: BigInt,
|
pub id: BigInt,
|
||||||
pub uses: Option<BigInt>,
|
pub uses: Option<BigInt>,
|
||||||
@ -94,8 +97,8 @@ impl FromDB<Invite, bool> for Invite {
|
|||||||
let mapping_r = query.map_and_drop(|row| {
|
let mapping_r = query.map_and_drop(|row| {
|
||||||
let (id, uses): (BigInt, Option<BigInt>) = mysql_async::from_row(row);
|
let (id, uses): (BigInt, Option<BigInt>) = mysql_async::from_row(row);
|
||||||
Invite {
|
Invite {
|
||||||
id: id,
|
id,
|
||||||
uses: uses,
|
uses,
|
||||||
expires: expirey_flag
|
expires: expirey_flag
|
||||||
}
|
}
|
||||||
}).await;
|
}).await;
|
||||||
@ -120,8 +123,8 @@ impl Invite {
|
|||||||
|
|
||||||
Invite {
|
Invite {
|
||||||
id: (Utc::now() + chrono::Duration::minutes(30)).timestamp(),
|
id: (Utc::now() + chrono::Duration::minutes(30)).timestamp(),
|
||||||
uses: uses,
|
uses,
|
||||||
expires: expires
|
expires
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn add(&self, p: &Pool) -> Result<(), SqlError> {
|
pub async fn add(&self, p: &Pool) -> Result<(), SqlError> {
|
||||||
|
Loading…
Reference in New Issue
Block a user