Skip to content

Implement iCal API endpoint for event calendar subscriptions#31

Merged
JonLatane merged 5 commits intomainfrom
copilot/fix-30
Jul 12, 2025
Merged

Implement iCal API endpoint for event calendar subscriptions#31
JonLatane merged 5 commits intomainfrom
copilot/fix-30

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 8, 2025

This PR implements the ical_subscription web endpoint that serves iCal formatted calendar data for user events, as requested in the issue.

Changes Made

Core Implementation

  • Replaced placeholder code in backend/src/web/ical_subscription.rs with a complete iCal generation implementation
  • Changed parameter from _user_id to user_id and properly use it to filter events by author
  • Added icalendar crate dependency (v0.16.7) to Cargo.toml for RFC 5545 compliant calendar generation

API Behavior

  • Endpoint: GET /calendar.ics?user_id=<id>
  • Returns: Proper iCal format with text/calendar content type
  • Anonymous access: Uses get_events RPC without user authentication as specified
  • Event filtering: Fetches events where the specified user is the author

iCal Generation

  • Maps EventInstances to individual iCal events (no recurrence handling as specified)
  • Event details: Uses Event.post for title/description, EventInstance for start/end times
  • Location support: Includes event location from EventInstance.location.uniformly_formatted_address
  • Event links: Adds "via: https://{frontend_domain}/event/{instance_id}" to descriptions (matching frontend behavior)

Technical Details

  • Time conversion: Uses existing ToDbTime marshaling trait for proper timestamp handling
  • Frontend domain: Leverages configured_frontend_domain() helper for correct link generation
  • Error handling: Returns appropriate error messages for missing parameters or RPC failures
  • Trait imports: Added EventLike trait import to enable .starts() and .ends() methods

Testing

  • Unit test: Added comprehensive test for iCal generation logic
  • Build verification: Code compiles successfully with only existing warnings
  • Format validation: Test confirms proper iCal structure (BEGIN/END blocks, required fields)

Example Usage

# Get iCal calendar for user with ID "user123"
curl "https://yourserver.com/calendar.ics?user_id=user123"

Returns RFC 5545 compliant iCal data that can be imported into any calendar application.

Fixes #30.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits July 8, 2025 17:24
Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com>
Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com>
Co-authored-by: JonLatane <127916+JonLatane@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement iCal API Implement iCal API endpoint for event calendar subscriptions Jul 8, 2025
Copilot AI requested a review from JonLatane July 8, 2025 17:41
@JonLatane JonLatane marked this pull request as ready for review July 12, 2025 21:08
@JonLatane JonLatane merged commit c9914fe into main Jul 12, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement iCal API

2 participants