namespace _zeitbild.api { /** */ export function register_davina_event_get( rest_subject : lib_plankton.rest_caldav.type_rest ) : void { register< null, (null | lib_plankton.ical.type_vcalendar) >( rest_subject, lib_plankton.http.enum_method.get, "/davina/event_get", { "query_parameters": () => ([ { "name": "calendar_id", "required": true, "description": "calendar ID", }, { "name": "event_id", "required": true, "description": "event ID", }, ]), "output_schema": () => ({ "nullable": false, "type": "string", }), "response_body_mimetype": "text/calendar", "response_body_encode": (output) => Buffer.from( (typeof(output) === "string") ? output : ( lib_plankton.ical.ics_encode(output) /** * @todo add event encoder function to plankton */ // .replace(new RegExp("[\\s\\S]*BEGIN:VEVENT([\\s\\S]*)END:VEVENT[\\s\\S]*", "m"), "BEGIN:VEVENT$1END:VEVENT") ) ), "restriction": restriction_web_auth, "execution": async (stuff) => { const user : {id : _zeitbild.type_user_id; object : _zeitbild.type_user_object;} = await _zeitbild.api.user_from_web_auth(stuff); const calendar_id : int = parseInt(stuff.query_parameters["calendar_id"]); const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.service.calendar.get(calendar_id, user.id); const event_id : int = parseInt(stuff.query_parameters["event_id"]); const event_object : _zeitbild.type_event_object = await _zeitbild.service.resource.event_get(calendar_object.resource_id, event_id); return Promise.resolve( { "status_code": 200, "data": _zeitbild.helpers.ical_vcalendar_from_own_event_list([event_object]), } ); } } ); } }