mirror of
https://github.com/flibusta-apps/telegram_files_cache_server.git
synced 2026-03-04 07:30:49 +01:00
Fix
This commit is contained in:
@@ -4,6 +4,8 @@ use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::config::CONFIG;
|
||||
|
||||
use self::types::{BaseBook, Page};
|
||||
|
||||
async fn _make_request<T>(
|
||||
url: &str,
|
||||
params: Vec<(&str, String)>,
|
||||
@@ -53,16 +55,13 @@ pub async fn get_books(
|
||||
page_size: u32,
|
||||
uploaded_gte: String,
|
||||
uploaded_lte: String,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let _params: Vec<(&str, String)> = vec![
|
||||
) -> Result<Page<BaseBook>, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let params: Vec<(&str, String)> = vec![
|
||||
("page", page.to_string()),
|
||||
("page_size", page_size.to_string()),
|
||||
("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(())
|
||||
_make_request(format!("/api/v1/books/base/").as_str(), params).await
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ pub struct BookWithRemote {
|
||||
pub authors: Vec<BookAuthor>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct BaseBook {
|
||||
pub id: i32,
|
||||
pub available_types: Vec<String>
|
||||
}
|
||||
|
||||
impl BookWithRemote {
|
||||
pub fn from_book(book: Book, remote_id: u32) -> Self {
|
||||
Self {
|
||||
@@ -106,3 +112,15 @@ impl BookWithRemote {
|
||||
format!("{caption_title}\n\n{caption_authors}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Deserialize, Debug, Clone)]
|
||||
pub struct Page<T> {
|
||||
pub items: Vec<T>,
|
||||
pub total: u32,
|
||||
|
||||
pub page: u32,
|
||||
|
||||
pub size: u32,
|
||||
pub pages: u32,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user