rust
ai slop
This commit is contained in:
1 parent
b4d6446c20
commit
89c19e365c
2 files changed
+30
-10
No files matched your search
@@ -26,12 +26,17 @@ A backend service for filtering `.ics` calendar files.
|
||||
|
||||
- Regex-based filtering for `.ics` files.
|
||||
- Support for include and exclude rules.
|
||||
- Written in Rust for performance and safety.
|
||||
- Written in Rust for ahhhhh
|
||||
|
||||
## API Endpoints
|
||||
|
||||
- `/filter`: Accepts `.ics` files and filtering rules.
|
||||
- `/status`: Returns the server status.
|
||||
- `/filter-ics`: Accepts `.ics` files and filtering rules.
|
||||
|
||||
## URL Arguments
|
||||
|
||||
- url: url for the `.ics` file
|
||||
- regex: Valid regex for exclude matching
|
||||
- include: Valid regex for include matching
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
+22
-7
@@ -30,13 +30,26 @@ async fn filtered_ics(
|
||||
.unwrap_or_else(|| "deadass dont know".into()),
|
||||
req.path()
|
||||
);
|
||||
let cuh = format!("url {}\ndone in", req.full_url());
|
||||
let _w = LdaTimer::new(&cuh);
|
||||
|
||||
let now = **now;
|
||||
let client = Client::new();
|
||||
let ics_url = query.get("url").map_or(ICS_URL, |d| {
|
||||
println!("ooh! url query from {d} idk if its good");
|
||||
d.as_str()
|
||||
});
|
||||
let ics_url = /* match */ query
|
||||
.get("url")
|
||||
.map_or(ICS_URL, |d| {
|
||||
// unwrap or
|
||||
println!("ooh! url query from {d} idk if its good");
|
||||
d.as_str()
|
||||
})
|
||||
/* .parse::<reqwest::Url>()
|
||||
{
|
||||
Ok(bro) => bro,
|
||||
Err(e) => {
|
||||
eprintln!("i told u ts not good: {e}");
|
||||
return HttpResponse::BadRequest().body(format!("Bad URL: {e}"));
|
||||
}
|
||||
} */;
|
||||
|
||||
// Fetch the .ics content
|
||||
let response = match client.get(ics_url).send().await {
|
||||
@@ -120,7 +133,7 @@ async fn filtered_ics(
|
||||
let filtered_events = filter_events_by_date_and_regex(
|
||||
calendar,
|
||||
regex_exclude_rules,
|
||||
regex_include_rules, // Pass include rule here
|
||||
regex_include_rules,
|
||||
start_date,
|
||||
end_date,
|
||||
);
|
||||
@@ -164,12 +177,12 @@ fn filter_events_by_date_and_regex(
|
||||
return Some(component);
|
||||
};
|
||||
|
||||
let start = event.get_start()?.date_naive();
|
||||
let start = event.get_start()?.date_naive(); // snipe if no date :buh:
|
||||
if start < start_date || start > end_date {
|
||||
return None;
|
||||
}
|
||||
|
||||
let summary = event.get_summary()?;
|
||||
let summary = event.get_summary()?; // snipe if no summary Huh
|
||||
|
||||
// Apply exclude rule
|
||||
if let Some(reg) = &exclude_pattern {
|
||||
@@ -226,6 +239,8 @@ mod funny_timer;
|
||||
|
||||
use actix_web::dev::ServerHandle;
|
||||
|
||||
use crate::funny_timer::LdaTimer;
|
||||
|
||||
#[post("/die")]
|
||||
async fn die(shutdown: web::Data<Arc<Mutex<Option<ServerHandle>>>>) -> impl Responder {
|
||||
// Trigger shutdown in a new task so we can respond first
|
||||
|
||||
Reference in new issue
Block a user