[task-192] caldav-API-Aktionen entfernen

This commit is contained in:
Fenris Wolf 2025-09-04 09:54:28 +00:00
parent fc228fb274
commit 5ab91664ed
6 changed files with 0 additions and 645 deletions

View file

@ -1,236 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_get(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
null,
/*
(
null
|
string
|
lib_plankton.ical.type_vcalendar
)
*/
(
null
|
lib_plankton.xml.type_node_data
)
>(
rest_subject,
lib_plankton.caldav.enum_method.report,
"/caldav/project/:id",
{
"description": "trägt Veranstaltungen aus verschiedenen Kalendern zusammen im ical-Format",
"query_parameters": () => ([
{
"name": "from",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "to",
"required": false,
"description": "UNIX timestamp",
},
{
"name": "calendar_ids",
"required": false,
"description": "comma separated",
},
{
"name": "auth",
"required": true,
"description": "",
},
]),
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
/*
"response_body_mimetype": "text/calendar",
"response_body_encode": (output) => (
(output === null)
?
null
:
Buffer.from(
(typeof(output) === "string")
?
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,
/**
* @todo use stuff.path_parameters["id"]
*/
"execution": async (stuff) => {
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
stuff.headers["Authorization"]
??
stuff.headers["authorization"]
??
null
);
if (user_id === null) {
return Promise.resolve(
{
"status_code": 401,
"data": null,
"extra_headers": {
"WWW-Authenticate": "Basic realm=Restricted",
}
}
);
}
else {
const from : lib_plankton.pit.type_pit = (
("from" in stuff.query_parameters)
?
parseInt(stuff.query_parameters["from"])
:
lib_plankton.pit.shift_week(
lib_plankton.pit.now(),
-2
)
);
const to : lib_plankton.pit.type_pit = (
("to" in stuff.query_parameters)
?
parseInt(stuff.query_parameters["to"])
:
lib_plankton.pit.shift_week(
lib_plankton.pit.now(),
+6
)
);
const calendar_ids_wanted : (null | Array<_zeitbild.type_calendar_id>) = (
(
("calendar_ids" in stuff.query_parameters)
&&
(stuff.query_parameters["calendar_ids"] !== null)
)
?
lib_plankton.call.convey(
stuff.query_parameters["calendar_ids"],
[
(x : string) => x.split(","),
(x : Array<string>) => x.map(parseInt),
(x : Array<int>) => x.filter(y => (! isNaN(y)))
]
)
:
null
);
return (
_zeitbild.service.calendar.gather_events(
calendar_ids_wanted,
from,
to,
user_id
)
.then(
(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",
}
*/
_zeitbild.helpers.ical_vcalendar_from_own_event_list(
data
.map(
entry => entry.event_object
)
)
)
}
},
],
"status": "HTTP/1.1 200 OK",
"description": null,
}
]
},
"description": null
})
)
),
"description": null
}
)
}
)
)
.catch(
(reason) => Promise.resolve(
{
"status_code": 403,
"data": /*String(reason)*/null,
}
)
)
);
}
}
}
);
}
}

View file

@ -1,109 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_probe(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
(
null
|
lib_plankton.xml.type_node_data
),
lib_plankton.xml.type_node_data
>(
rest_subject,
lib_plankton.caldav.enum_method.propfind,
"/caldav",
{
"request_body_mimetype": () => "text/xml",
"request_body_decode": () => async (body, header_content_type) => (
(
(header_content_type !== null)
&&
(
(header_content_type.startsWith("text/xml"))
||
(header_content_type.startsWith("application/xml"))
)
)
?
lib_plankton.xml.parse(body.toString())
:
Promise.resolve<any>(null)
),
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
"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_basic_auth,
"restriction": restriction_none,
"execution": async (stuff) => {
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
stuff.headers["Authorization"]
??
stuff.headers["authorization"]
??
null
);
if (user_id === null) {
return Promise.resolve(
{
"status_code": 401,
"data": {
"kind": "text",
"data": ""
},
"extra_headers": {
"WWW-Authenticate": "Basic realm=Restricted",
}
}
);
}
else {
const output : (null | lib_plankton.xml.type_node_data) = _zeitbild.service.caldav.probe(
stuff.input
);
if (output !== null) {
return Promise.resolve(
{
"status_code": 207,
"data": output
}
);
}
else {
return Promise.resolve(
{
"status_code": 501,
"data": {
"kind": "root",
"data": {
"version": "1.0",
"encoding": "utf-8",
"content": {
"kind": "text",
"data": ""
}
}
}
}
);
}
}
}
}
);
}
}

View file

@ -1,115 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_probe_via_well_known(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
(
null
|
lib_plankton.xml.type_node_data
),
lib_plankton.xml.type_node_data
>(
rest_subject,
lib_plankton.caldav.enum_method.propfind,
"/.well-known/caldav",
{
"request_body_mimetype": () => "text/xml",
"request_body_decode": () => async (body, header_content_type) => (
(
(header_content_type !== null)
&&
(
(header_content_type.startsWith("text/xml"))
||
(header_content_type.startsWith("application/xml"))
)
)
?
lib_plankton.xml.parse(body.toString())
:
Promise.resolve<any>(null)
),
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
"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_basic_auth,
"restriction": restriction_none,
"execution": async (stuff) => {
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
stuff.headers["Authorization"]
??
stuff.headers["authorization"]
??
null
);
if (user_id === null) {
return Promise.resolve(
{
"status_code": 401,
"data": {
"kind": "text",
"data": ""
},
"extra_headers": {
"WWW-Authenticate": "Basic realm=Restricted",
}
}
);
}
else {
const output : (null | lib_plankton.xml.type_node_data) = _zeitbild.service.caldav.probe(
stuff.input,
{
"force_props": [
"D:displayname",
"D:resourcetype",
]
}
);
if (output !== null) {
return Promise.resolve(
{
"status_code": 207,
"data": output
}
);
}
else {
return Promise.resolve(
{
"status_code": 501,
"data": {
"kind": "root",
"data": {
"version": "1.0",
"encoding": "utf-8",
"content": {
"kind": "text",
"data": ""
}
}
}
}
);
}
}
}
}
);
}
}

View file

@ -1,107 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_projects(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
lib_plankton.xml.type_node_data,
(
null
|
lib_plankton.xml.type_node_data
)
>(
rest_subject,
lib_plankton.caldav.enum_method.propfind,
"/caldav/project",
{
"output_schema": () => ({
"nullable": false,
"type": "string",
}),
"request_body_mimetype": () => "text/xml",
"request_body_decode": () => async (body, header_content_type) => (
(
(header_content_type !== null)
&&
(
(header_content_type.startsWith("text/xml"))
||
(header_content_type.startsWith("application/xml"))
)
)
?
lib_plankton.xml.parse(body.toString())
:
Promise.resolve<any>(null)
),
"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_basic_auth,
"restriction": restriction_none,
/**
* @todo heed stuff.input
*/
"execution": async (stuff) => {
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
stuff.headers["Authorization"]
??
stuff.headers["authorization"]
??
null
);
if (user_id === null) {
return Promise.resolve(
{
"status_code": 401,
"data": {
"kind": "text",
"data": ""
},
"extra_headers": {
"WWW-Authenticate": "Basic realm=Restricted",
}
}
);
}
else {
if (stuff.input === null) {
return Promise.resolve(
{
"status_code": 400,
"data": null,
}
);
}
else {
return (
_zeitbild.service.caldav.projects(
stuff.input,
user_id
)
.then(
(output) => Promise.resolve(
{
"status_code": 207,
"data": output,
}
)
)
);
}
}
}
}
);
}
}

View file

@ -1,32 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_put(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
null,
null
>(
rest_subject,
lib_plankton.caldav.enum_method.put,
"/caldav",
{
"restriction": restriction_none,
"execution": async (stuff) => {
return Promise.resolve(
{
"status_code": 200,
"data": null
}
);
}
}
);
}
}

View file

@ -1,46 +0,0 @@
namespace _zeitbild.api
{
/**
*/
export function register_caldav_sniff(
rest_subject : lib_plankton.rest_caldav.type_rest
) : void
{
register<
any,
null
>(
rest_subject,
lib_plankton.caldav.enum_method.options,
"/caldav",
{
"restriction": restriction_none,
"execution": async (stuff) => {
const permitted : boolean = await restriction_basic_auth(stuff);
if (! permitted) {
return Promise.resolve(
{
"status_code": 401,
"data": null,
"extra_headers": {
"WWW-Authenticate": "Basic realm=Restricted",
}
}
);
}
else {
return Promise.resolve(
{
"status_code": 200,
"data": null
}
);
}
}
}
);
}
}