[mod] api:caldav_get

This commit is contained in:
Fenris Wolf 2024-11-29 08:44:05 +01:00
parent 8ddba38bd5
commit 6f1437b55a

View file

@ -10,6 +10,7 @@ namespace _zeitbild.api
{ {
register< register<
null, null,
/*
( (
null null
| |
@ -17,6 +18,12 @@ namespace _zeitbild.api
| |
lib_plankton.ical.type_vcalendar lib_plankton.ical.type_vcalendar
) )
*/
(
null
|
lib_plankton.xml.type_node_data
)
>( >(
rest_subject, rest_subject,
lib_plankton.caldav.enum_method.report, lib_plankton.caldav.enum_method.report,
@ -49,6 +56,7 @@ namespace _zeitbild.api
"nullable": false, "nullable": false,
"type": "string", "type": "string",
}), }),
/*
"response_body_mimetype": "text/calendar", "response_body_mimetype": "text/calendar",
"response_body_encode": (output) => ( "response_body_encode": (output) => (
(output === null) (output === null)
@ -62,6 +70,13 @@ namespace _zeitbild.api
: :
lib_plankton.ical.ics_encode(output) lib_plankton.ical.ics_encode(output)
) )
),
*/
"response_body_mimetype": "text/xml",
"response_body_encode": output => Promise.resolve<Buffer>(
Buffer.from(
lib_plankton.xml.get_node_logic(output).compile(0)
)
), ),
"restriction": restriction_none, "restriction": restriction_none,
/** /**
@ -137,9 +152,61 @@ namespace _zeitbild.api
(data) => Promise.resolve( (data) => Promise.resolve(
{ {
"status_code": 200, "status_code": 200,
/*
"data": _zeitbild.helpers.ical_vcalendar_from_own_event_list( "data": _zeitbild.helpers.ical_vcalendar_from_own_event_list(
data.map(entry => entry.event_object) 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( (reason) => Promise.resolve(
{ {
"status_code": 403, "status_code": 403,
"data": String(reason), "data": /*String(reason)*/null,
} }
) )
) )