diff --git a/src/db.rs b/src/db.rs index ace23dc..b7fcf27 100644 --- a/src/db.rs +++ b/src/db.rs @@ -3,6 +3,45 @@ use sqlx::{Sqlite, SqlitePool}; use super::util::make_database_url; + +#[derive(sqlx::FromRow)] +pub struct User { + pub id: i64, + pub tg_id: i64, + pub username: Option, + pub first_name: String, + pub last_name: Option, + pub can_download: i64, + pub is_admin: i64, +} + +#[derive(sqlx::FromRow)] +pub struct Chat { + pub id: i64, + pub tg_id: i64, + pub username: Option, + pub title: String, + pub can_download: i64 +} + +#[derive(sqlx::FromRow)] +pub struct Link { + pub id: i64, + pub domain: String, + pub path: Option, + pub download_allowed: i64, + pub auto_download: i64 +} + +#[derive(sqlx::FromRow)] +pub struct Request { + pub id: i64, + pub requested_by: i64, + pub approved_by: Option, + pub message: Option, + pub is_approved: i64 +} + pub async fn db_init() -> SqlitePool { let db_url = make_database_url(); if !Sqlite::database_exists(&db_url).await.unwrap_or(false) { @@ -15,4 +54,4 @@ pub async fn db_init() -> SqlitePool { sqlx::migrate!().run(&db).await.unwrap(); db -} +} \ No newline at end of file