Files
calendar/backend/src/debug_caldav.rs
Connor Johnstone e55e6bf4dd
Some checks failed
Build and Push Docker Image / docker (push) Failing after 2s
Clean up obsolete CalDAV environment variables
## Removed Obsolete Environment Variables:
- `CALDAV_SERVER_URL` - provided by user login
- `CALDAV_USERNAME` - provided by user login
- `CALDAV_PASSWORD` - provided by user login
- `CALDAV_TASKS_PATH` - not used in any features

## Kept with Intelligent Discovery:
- `CALDAV_CALENDAR_PATH` - optional override, defaults to smart discovery

## Changes:
### Backend
- Remove `CalDAVConfig::from_env()` method (not used in main app)
- Add `CalDAVConfig::new()` constructor with credentials
- Remove `tasks_path` field from CalDAVConfig
- Update auth service to use new constructor
- Update tests to use hardcoded test values instead of env vars
- Update debug tools to use test credentials

### Frontend
- Remove unused `config.rs` file entirely (frontend uses backend API)

## Current Authentication Flow:
1. User provides CalDAV credentials via login API
2. Backend creates CalDAVConfig dynamically from login request
3. Backend tests authentication via calendar discovery
4. Optional `CALDAV_CALENDAR_PATH` env var can override discovery
5. No environment variables required for normal operation

This simplifies deployment - users only need to provide CalDAV
credentials through the web interface, no server-side configuration required.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 19:48:13 -04:00

66 lines
2.4 KiB
Rust

use crate::calendar::CalDAVClient;
use crate::config::CalDAVConfig;
pub async fn debug_caldav_fetch() -> Result<(), Box<dyn std::error::Error>> {
// Use debug/test configuration
let config = CalDAVConfig::new(
"https://example.com".to_string(),
"debug_user".to_string(),
"debug_password".to_string()
);
let client = CalDAVClient::new(config);
println!("=== DEBUG: CalDAV Fetch ===");
// Discover calendars
let calendars = client.discover_calendars().await?;
println!("Found {} calendars: {:?}", calendars.len(), calendars);
if let Some(calendar_path) = calendars.first() {
println!("Fetching events from: {}", calendar_path);
// Make the raw REPORT request
let report_body = r#"<?xml version="1.0" encoding="utf-8" ?>
<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
<d:prop>
<d:getetag/>
<c:calendar-data/>
</d:prop>
<c:filter>
<c:comp-filter name="VCALENDAR">
<c:comp-filter name="VEVENT"/>
</c:comp-filter>
</c:filter>
</c:calendar-query>"#;
let url = format!("{}{}", client.config.server_url.trim_end_matches('/'), calendar_path);
println!("Request URL: {}", url);
let response = client.http_client
.request(reqwest::Method::from_bytes(b"REPORT").unwrap(), &url)
.header("Authorization", format!("Basic {}", client.config.get_basic_auth()))
.header("Content-Type", "application/xml")
.header("Depth", "1")
.header("User-Agent", "calendar-app/0.1.0")
.body(report_body)
.send()
.await?;
println!("Response status: {}", response.status());
let body = response.text().await?;
println!("Response body length: {}", body.len());
println!("First 500 chars of response: {}", &body[..std::cmp::min(500, body.len())]);
// Try to parse it
let events = client.parse_calendar_response(&body)?;
println!("Parsed {} events", events.len());
for (i, event) in events.iter().enumerate() {
println!("Event {}: {}", i+1, event.summary.as_deref().unwrap_or("No title"));
println!(" Start: {}", event.start);
println!(" UID: {}", event.uid);
}
}
Ok(())
}