diff --git a/src/feed_utils.rs b/src/feed_utils.rs index 00d3b12..2d2000f 100644 --- a/src/feed_utils.rs +++ b/src/feed_utils.rs @@ -1,4 +1,5 @@ -use feed_rs; +use feed_rs::model::Feed; +use feed_rs::parser; use std::time::Duration; use tracing::{error, info}; use url::Url; @@ -6,7 +7,7 @@ use url::Url; #[derive(Debug)] pub struct FeedError; -pub async fn fetch_feed(url: &Url) -> Result { +pub async fn fetch_feed(url: &Url) -> Result { info!("Making a request to fetch feed `{url}`"); // Create a client with a 10 second timeout @@ -34,7 +35,7 @@ pub async fn fetch_feed(url: &Url) -> Result { })?; // Parse the feed - let feed_data = feed_rs::parser::parse(content.as_bytes()).map_err(|e| { + let feed_data = parser::parse(content.as_bytes()).map_err(|e| { error!("Failed to parse feed content: {}", e); FeedError })?; diff --git a/src/import.rs b/src/import.rs index df4dc94..de36d9c 100644 --- a/src/import.rs +++ b/src/import.rs @@ -1,21 +1,16 @@ // Module for handling OPML feed list imports use std::io::Cursor; -use std::io::Read; use quick_xml::de::from_reader; use rocket::data::ToByteUnit; -use rocket::form::Form; -use rocket::fs::TempFile; use rocket::http::Status; use rocket::serde::json::Json; use rocket::serde::{Deserialize, Serialize}; -use rocket::tokio::io::AsyncReadExt; use rocket::{post, Data, State}; use rocket_db_pools::Connection; use tokio::spawn; -use tracing::{error, info}; -use url::Url; +use tracing::error; use uuid::Uuid; use crate::feed_utils::fetch_feed; @@ -75,11 +70,6 @@ impl OpmlOutline { } } -#[derive(FromForm)] -pub struct UploadForm<'f> { - file: TempFile<'f>, -} - /// Import feeds from an OPML file #[post("/import/opml", data = "")] pub async fn import_opml( @@ -216,7 +206,7 @@ async fn import_feeds_job( imported_count += 1; } } - Err(e) => { + Err(_) => { error!("Failed to fetch or parse feed from {url}"); } }