+ 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::error::Error as SqlError;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{UBigInt, BigInt};
|
||||
@ -9,6 +11,7 @@ use crate::common::FromDB;
|
||||
use crate::{Response, no_conn};
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Serialize)]
|
||||
pub struct Invite {
|
||||
pub id: BigInt,
|
||||
pub uses: Option<BigInt>,
|
||||
@ -94,8 +97,8 @@ impl FromDB<Invite, bool> for Invite {
|
||||
let mapping_r = query.map_and_drop(|row| {
|
||||
let (id, uses): (BigInt, Option<BigInt>) = mysql_async::from_row(row);
|
||||
Invite {
|
||||
id: id,
|
||||
uses: uses,
|
||||
id,
|
||||
uses,
|
||||
expires: expirey_flag
|
||||
}
|
||||
}).await;
|
||||
@ -120,8 +123,8 @@ impl Invite {
|
||||
|
||||
Invite {
|
||||
id: (Utc::now() + chrono::Duration::minutes(30)).timestamp(),
|
||||
uses: uses,
|
||||
expires: expires
|
||||
uses,
|
||||
expires
|
||||
}
|
||||
}
|
||||
pub async fn add(&self, p: &Pool) -> Result<(), SqlError> {
|
||||
|
Loading…
Reference in New Issue
Block a user