Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calsub: Add JSON as a supported format for calendar subscriptions #4196

Merged
merged 3 commits into from
Dec 23, 2024

Conversation

mastercactapus
Copy link
Member

Description:
Adding support for Accept: application/json on calendar subscription requests.

This pull request introduces several changes to the calsub/http.go file, primarily enhancing the functionality to support JSON responses and refactoring existing code to improve maintainability.

  • Added a new constant PayloadType and types JSONResponseV1 and JSONShiftV1 to structure JSON responses for calendar subscriptions.
  • Modified the ServeICalData function to handle requests with Accept: application/json header, constructing and returning a JSON response with schedule and user shift details.
  • Introduced the userNameMap function to encapsulate the logic for fetching and mapping user names from user IDs, replacing the inline code in ServeICalData.
  • Refactored the code within ServeICalData to use the new userNameMap function, simplifying the logic for populating user names in the full schedule rendering.
  • Added a smoke test that validates both the default response as well as the new JSON response.

Describe any introduced API changes:
Calendar subscription requests including Accept: application/json will return JSON instead of ICAL data.

@mastercactapus mastercactapus merged commit 5593d7c into master Dec 23, 2024
7 checks passed
@mastercactapus mastercactapus deleted the cal-sub-json branch December 23, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants