-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Epic: #251
We need to implement a new REST API route to allow updating the participation status (ACCEPTED
/ DECLINED
) of a resource.
How
Endpoint format:
/calendar/api/resources/{resourceId}/{eventId}/participation?status={partStat}&referrer=email
resourceId
: Mongo collectionresources._id
eventId
: sabredav event identifier (e.g.sabredav-70d3d28f-..
.)partStat
:ACCEPTED
orDECLINED
referrer
: fixed value =email
Expected response:
TODO: Should be aligned with legacy OpenPaas behavior.
Route implementation
- Create new route class in
calendar-rest-api
module, Suggested name:ResourceParticipationRoute
. - Validation logic:
- Ensure both authentication and authorization.
- [authorization] Check
resources.administrators
field: Only users whoseopenpaasId
is listed in this collection are authorized.
Example:
[
{"_id": ObjectId("68a5850f0873000079ba2ce1"), "id": "68a584caa5eb6f005001c251", "objectType": "user"},
{"_id": ObjectId("68a58a300873000079ba2cf6"), "id": "68a584caa5eb6f005001c257", "objectType": "user"}
]
Update to SabreDAV
- Update
partstat
using technical user token.⚠️ Note: even if a user is listed as administrator in the resource, they cannot directly update. Only the technical user token works.- authenticated client (implemented): CardDavClient#authenticatedClientByToken
- Add new method in
CalDavEventRepository
:
public Mono<CalendarEventReportResponse> updateResourcePartStat(
Username resourceUsername,
OpenPaaSId resourceId,
String eventId,
PartStat partStat
)
- Logic is similar to existing updatePartStat(...) but with one difference: Since we already have the
eventId
(part ofeventPath
), there is no need to query Dav by UID to get eventPath (viaclient.calendarReportByUid
) - Example request
curl --location --request PUT \
'http://localhost:8001/calendars/68a5850f0873000079ba2ce0/68a5850f0873000079ba2ce0/sabredav-70d3d28f-7cfe-43f5-afad-1d49271d366d.ics' \
--header 'TwakeCalendarToken: 73228f19-fc38-4e9f-a5f7-4266ba62d663' \
--header 'Content-Type: text/plain' \
--data-raw 'BEGIN:VCALENDAR
...
END:VCALENDAR'
- SabreDAV responds with HTTP 204 when update succeeds. (a message is published to exchange
resource:calendar:event:created
)
chibenwa