61 lines
1.5 KiB
Rust
61 lines
1.5 KiB
Rust
use crate::schema::{invites, users, channels, sessions};
|
|
#[derive(Insertable, Serialize, Deserialize, Queryable, Debug)]
|
|
#[table_name = "invites"]
|
|
pub struct Invite {
|
|
pub id: u64,
|
|
pub expires: u64,
|
|
pub uses: i32,
|
|
}
|
|
|
|
|
|
#[derive(Insertable)]
|
|
#[table_name = "users"]
|
|
pub struct InsertableUser {
|
|
pub name: String,
|
|
pub secret: String,
|
|
pub date: u64,
|
|
pub status: i32,
|
|
}
|
|
|
|
// NOTE: Insertable is the only rls stop complaining at us about `table_name` not being found in scope
|
|
// its dumb but its how we're going to compile this, with some dead code
|
|
#[derive(Insertable, Serialize, Deserialize, Queryable, Debug)]
|
|
#[table_name = "users"]
|
|
pub struct User {
|
|
pub id: u64,
|
|
pub name: String,
|
|
pub secret: String,
|
|
pub date: u64,
|
|
pub status: i32,
|
|
}
|
|
|
|
pub const USER_OFFLINE: i32 = 1;
|
|
pub const _USER_ONLINE: i32 = 2;
|
|
pub const _USER_AWAY: i32 = 3;
|
|
pub const _USER_DO_NOT_DISTRUB: i32 = 4;
|
|
|
|
#[derive(Serialize, Deserialize, Queryable, Insertable)]
|
|
#[table_name = "channels" ]
|
|
pub struct Channel {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub permissions: i32,
|
|
pub limit: i32, // <= 0 means there is no limit
|
|
pub type_: i32, // 1 for voice 2 for text
|
|
}
|
|
|
|
#[derive(Insertable)]
|
|
#[table_name = "channels"]
|
|
pub struct InsertableChannel {
|
|
pub name: String,
|
|
pub permissions: i32,
|
|
pub limit: i32, // <= 0 means there is no limit
|
|
pub type_: i32, // 1 for voice 2 for text
|
|
}
|
|
|
|
#[derive(Insertable)]
|
|
#[table_name = "sessions"]
|
|
pub struct InsertableSession {
|
|
pub secret: String,
|
|
pub expires: u64,
|
|
} |