-
Notifications
You must be signed in to change notification settings - Fork 101
Add plugin API get/set slots handlers #198
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
base: main
Are you sure you want to change the base?
Conversation
frontend/src/utils/sign_in_utils.js
Outdated
| }) => { | ||
| const clientId = | ||
| "523323684219-jfakov2bgsleeb6den4ktpohq4lcnae2.apps.googleusercontent.com" | ||
| "447891895572-fkf9aidtg8cr356u6cbgvrm0gruh4t65.apps.googleusercontent.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to change this back before the final commit, fine for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, will do that in the commit with the docs
| <v-btn | ||
| v-if="event.startOnMonday ? weekOffset != 1 : weekOffset != 0" | ||
| :icon="isPhone" | ||
| text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why this was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably by mistake, added it back for the next commit.
|
Great work so far! Some notes:
|
Fixed this. I added validation to ensure that the inputted dates belong to the set of DOW constants in case the event is of type
valid, added this capability. if a user is not logged in and haven't already added availability as a guest (i.e. |
I think it's a little awkward to have it so that users who are logged in or added availability as a guest cannot add / edit guest availability. Is it possible to make it so that if |
…n users, update docs
@jonyTF , done, updated this. logic is now basically:
|

Closes #189
Plugin API: get-slots and set-slots
This PR implements the
get-slotsandset-slotsmethods for the plugin API, allowing external plugins to retrieve and update user availability for events.Commits
This PR includes the following commits:
4cf5333- add get-slots event handlerccd51db- add set-slots logic, add plugin utility methodsecaa4b9- finish get and set slots event handlersOverview
A message handler (
handleMessage) was added to the Event component that routes plugin API requests to the appropriate handler method. Plugins communicate with the frontend viawindow.postMessage, and responses are sent back using the same mechanism.Message Handler
The
handleMessagemethod validates incoming messages and routes them to the appropriate handler:payload.type === "get-slots"are routed togetSlots()payload.type === "set-slots"are routed tosetSlots()Request Format
All plugin API requests must follow this format:
get-slots
Description
Retrieves availability slots for all respondents to an event. Returns slots in the user's local timezone (converted from UTC).
Request Format
Optional payload fields:
Response Format
Success response:
Error response:
Example Request
Timezone Conversion
get-slotsconverts UTC timestamps to the user's local timezone before returninglocalStorage["timezone"].value(if set)Intl.DateTimeFormat().resolvedOptions().timeZone)"2026-01-07T09:00:00")Limitations
/events/{eventId}/responses?timeMin={timestamp}&timeMax={timestamp}currently returns all respondents regardless of this setting. As a result,get-slotsmay expose all respondents' details and availability even when privacy is enabled. I'll raise an issue to fix this soon, but I think it's a fix to be made on the backend and not to this API.set-slots
Description
Sets availability slots for the current user (logged-in user or guest). Converts timestamps from the user's timezone to UTC before storing in the backend. Overwrites existing availability (does not merge).
Request Format
Required payload fields:
slots: Array of slot objects, each with:start: Start time (ISO string without timezone)end: End time (ISO string without timezone)status: Either"available"or"if-needed"Optional payload fields:
timezone: IANA timezone name (e.g.,"America/Los_Angeles","Asia/Kolkata"). If not provided, useslocalStorage["timezone"].valueor browser's local timezone.Response Format
Success response:
Error response:
Example Request
Timezone Conversion
set-slotsconverts these timestamps to UTC before sending to the backendpayload.timezone(if provided in the request)localStorage["timezone"].value(if set)Intl.DateTimeFormat().resolvedOptions().timeZone)timeIncrement(15, 30, or 60 minutes)Validation
start<endfor each slotstatusis either"available"or"if-needed"Limitations
set-slotswill NOT work for those guest accounts. It only works for:localStorage[eventId + ".guestName"]. This means guests must add their availability through the UI at least once before using the plugin API. Returns an error if guest name is not found.How It Works
localStorageevent.timeIncrement/events/:eventId/response(overwrites existing availability)Implementation Details
Helper Functions Added
convertUTCSlotsToLocalISO()- Converts UTC timestamps to user's local timezone (ISO format without timezone)frontend/src/utils/date_utils.jsfor reusabilityCode Organization
frontend/src/views/Event.vue(handleMessage,getSlots,setSlots)frontend/src/utils/plugin_utils.js(sendPluginSuccess,sendPluginError,isValidPluginMessage)frontend/src/utils/date_utils.js(convertUTCSlotsToLocalISO,convertToUTC,isTimeWithinEventRange)Testing
Use the browser console to test (don't forget to add listeners to intercept error/success messages):
Get slots:
Set slots: