diff --git a/source/api/actions/caldav_get.ts b/source/api/actions/caldav_get.ts index f66b99e..28c35aa 100644 --- a/source/api/actions/caldav_get.ts +++ b/source/api/actions/caldav_get.ts @@ -10,6 +10,7 @@ namespace _zeitbild.api { register< null, + /* ( null | @@ -17,6 +18,12 @@ namespace _zeitbild.api | lib_plankton.ical.type_vcalendar ) + */ + ( + null + | + lib_plankton.xml.type_node_data + ) >( rest_subject, lib_plankton.caldav.enum_method.report, @@ -49,6 +56,7 @@ namespace _zeitbild.api "nullable": false, "type": "string", }), + /* "response_body_mimetype": "text/calendar", "response_body_encode": (output) => ( (output === null) @@ -62,6 +70,13 @@ namespace _zeitbild.api : lib_plankton.ical.ics_encode(output) ) + ), + */ + "response_body_mimetype": "text/xml", + "response_body_encode": output => Promise.resolve( + Buffer.from( + lib_plankton.xml.get_node_logic(output).compile(0) + ) ), "restriction": restriction_none, /** @@ -137,9 +152,61 @@ namespace _zeitbild.api (data) => Promise.resolve( { "status_code": 200, + /* "data": _zeitbild.helpers.ical_vcalendar_from_own_event_list( data.map(entry => entry.event_object) ) + */ + "data": lib_plankton.webdav.data_multistatus_encode_xml( + { + "responses": ( + /** + * @todo find proper solution for null values + */ + data + .filter( + entry => (entry.event_id !== null) + ) + .map( + entry => ({ + "href": lib_plankton.string.coin( + "/caldav/project/{{calendar_id}}/{{event_id}}", + { + "calendar_id": stuff.path_parameters["id"], + "event_id": (entry.event_id ?? 0).toFixed(0), + } + ), + "body": { + "propstats": [ + { + "prop": [ + { + "name": "C:calendar-data", + "value": { + "kind": "primitive", + "data": lib_plankton.ical.ics_encode( + { + "version": "2.0", + "prodid": "zeitbild", + "vevents": [], + "method": "publish", + } + ), + } + }, + ], + "status": "HTTP/1.1 200 OK", + "description": null, + } + ] + }, + "description": null + }) + ) + ), + "description": null + } + ) } ) ) @@ -147,7 +214,7 @@ namespace _zeitbild.api (reason) => Promise.resolve( { "status_code": 403, - "data": String(reason), + "data": /*String(reason)*/null, } ) )