mirror of
https://github.com/flibusta-apps/telegram_files_cache_server.git
synced 2025-12-06 14:45:36 +01:00
Fix
This commit is contained in:
@@ -47,3 +47,22 @@ pub async fn get_book(
|
|||||||
) -> Result<types::BookWithRemote, Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<types::BookWithRemote, Box<dyn std::error::Error + Send + Sync>> {
|
||||||
_make_request(format!("/api/v1/books/{book_id}").as_str(), vec![]).await
|
_make_request(format!("/api/v1/books/{book_id}").as_str(), vec![]).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_books(
|
||||||
|
page: u32,
|
||||||
|
page_size: u32,
|
||||||
|
uploaded_gte: String,
|
||||||
|
uploaded_lte: String,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
|
let _params: Vec<(&str, String)> = vec![
|
||||||
|
("page", page.to_string()),
|
||||||
|
("page_size", page_size.to_string()),
|
||||||
|
("uploaded_gte", uploaded_gte),
|
||||||
|
("uploaded_lte", uploaded_lte)
|
||||||
|
];
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// _make_request(format!("/api/v1/books/").as_str(), params).await;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use reqwest::Response;
|
use reqwest::Response;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use tracing::log;
|
||||||
|
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
|
|
||||||
@@ -21,6 +22,8 @@ pub async fn download_from_downloader(
|
|||||||
CONFIG.downloader_url
|
CONFIG.downloader_url
|
||||||
);
|
);
|
||||||
|
|
||||||
|
log::info!("{url}");
|
||||||
|
|
||||||
let response = reqwest::Client::new()
|
let response = reqwest::Client::new()
|
||||||
.get(url)
|
.get(url)
|
||||||
.header("Authorization", &CONFIG.downloader_api_key)
|
.header("Authorization", &CONFIG.downloader_api_key)
|
||||||
|
|||||||
@@ -131,3 +131,9 @@ pub async fn download_from_cache(
|
|||||||
caption
|
caption
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn start_update_cache(
|
||||||
|
_db: Database
|
||||||
|
) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use tracing::Level;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{engine::general_purpose, Engine};
|
||||||
|
|
||||||
use crate::{config::CONFIG, db::get_prisma_client, prisma::{PrismaClient, cached_file::{self}}, services::{get_cached_file_or_cache, download_from_cache, download_utils::get_response_async_read}};
|
use crate::{config::CONFIG, db::get_prisma_client, prisma::{PrismaClient, cached_file::{self}}, services::{get_cached_file_or_cache, download_from_cache, download_utils::get_response_async_read, start_update_cache}};
|
||||||
|
|
||||||
|
|
||||||
pub type Database = Arc<PrismaClient>;
|
pub type Database = Arc<PrismaClient>;
|
||||||
@@ -92,9 +92,11 @@ async fn delete_cached_file(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn update_cache(
|
async fn update_cache(
|
||||||
_ext: Extension<Ext>
|
Extension(Ext { db, .. }): Extension<Ext>
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
StatusCode::OK.into_response() // TODO
|
tokio::spawn(start_update_cache(db));
|
||||||
|
|
||||||
|
StatusCode::OK.into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user