Skip to content

Conversation

GuilhermePSF
Copy link
Contributor

@GuilhermePSF GuilhermePSF commented Sep 17, 2025

Calendar Export (.ics)

This PR introduces a full-featured calendar export system for students in .ics format. Students can now generate a secure, short-lived URL to download their schedule and import it into external calendar apps (Google Calendar, Outlook, etc.).

Key features and changes

  • Secure calendar token support

    • Generates short-lived JWTs scoped specifically for calendar export.
    • Works without passing the student ID in the URL, the token identifies the user.
  • URL generator endpoint

    • GET /v1/export/student/calendar-url returns a signed URL with the token embedded.
    • Uses the current session to get the user_id and then generate the URL.
  • Calendar export endpoint

    • GET /v1/export/student/calendar.ics?token=... returns the .ics file.
    • Validates the token, fetches the corresponding student record, and exports all enrolled shifts.
  • Dynamic ICS content

    • Generates events from all student shifts.
  • Refactoring / module changes

    • Atlas.University updated with get_student_by_user_id/1 to get students via their user id.
    • AtlasWeb.AuthController made generate_token/3 public (please someone check if this is ok) and added calendar token support.
    • AtlasWeb.CalendarExportController handles both the URL generation and .ics export.
    • Router updated with the new routes for URL generation and calendar export.
  • Environment-aware URLs

    • ATLAS_API_URL environment variable sets the base URL for the api.
    • Defaults to http://localhost:4000 in development.
    • In production, set ATLAS_API_URL=https://pombo.cesium.pt/api so generated URLs include the correct host. (not sure how it should handle the /api, please someone help...
    • Ensures that calendar and API links are fully qualified and environment-specific.

Status / TODO

  • Still WIP regarding event recurrence and overrides, maybe we should make something so the app as the start and end of the semester, not sure. Maybe a bad/rudimentary idea is if a user is taking a timestamp when the calendar file URL is used and if it makes sense in the first semester it only repeats until 24 December and if it's in the 2nd semester maybe end in 1 July, this solution is weak due to the various activities and holiday/pauses in the classes.

👉 Preview a sample .ics file

@deployum
Copy link

deployum bot commented Sep 17, 2025

The preview deployment is ready. 🟢

Open Build Logs

Last updated at: 2025-09-21 00:10:45 CET

@GuilhermePSF GuilhermePSF self-assigned this Sep 21, 2025
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.

1 participant