2025-08-29 10:52:37 +00:00
|
|
|
|
|
|
|
namespace _zeitbild.api
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
export function register_davina_event_get(
|
|
|
|
rest_subject : lib_plankton.rest_caldav.type_rest
|
|
|
|
) : void
|
|
|
|
{
|
|
|
|
register<
|
|
|
|
null,
|
2025-09-04 07:46:49 +00:00
|
|
|
(null | lib_plankton.ical.type_vcalendar)
|
2025-08-29 10:52:37 +00:00
|
|
|
>(
|
|
|
|
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")
|
|
|
|
)
|
|
|
|
),
|
2025-09-04 07:46:49 +00:00
|
|
|
"restriction": restriction_web_auth,
|
2025-08-29 10:52:37 +00:00
|
|
|
"execution": async (stuff) => {
|
2025-09-04 07:46:49 +00:00
|
|
|
const user : {id : _zeitbild.type_user_id; object : _zeitbild.type_user_object;} = await _zeitbild.api.user_from_web_auth(stuff);
|
2025-08-29 10:52:37 +00:00
|
|
|
|
|
|
|
const calendar_id : int = parseInt(stuff.query_parameters["calendar_id"]);
|
2025-09-04 07:46:49 +00:00
|
|
|
const calendar_object : _zeitbild.type_calendar_object = await _zeitbild.service.calendar.get(calendar_id, user.id);
|
2025-08-29 10:52:37 +00:00
|
|
|
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]),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|