[task-192] [int]
This commit is contained in:
parent
6f1437b55a
commit
2cb46cd485
3 changed files with 227 additions and 84 deletions
|
@ -9,12 +9,12 @@ namespace _zeitbild.api
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
register<
|
register<
|
||||||
|
lib_plankton.xml.type_node_data,
|
||||||
(
|
(
|
||||||
null
|
null
|
||||||
|
|
|
|
||||||
lib_plankton.xml.type_node_data
|
lib_plankton.xml.type_node_data
|
||||||
),
|
)
|
||||||
lib_plankton.xml.type_node_data
|
|
||||||
>(
|
>(
|
||||||
rest_subject,
|
rest_subject,
|
||||||
lib_plankton.caldav.enum_method.propfind,
|
lib_plankton.caldav.enum_method.propfind,
|
||||||
|
@ -48,6 +48,9 @@ namespace _zeitbild.api
|
||||||
),
|
),
|
||||||
// "restriction": restriction_basic_auth,
|
// "restriction": restriction_basic_auth,
|
||||||
"restriction": restriction_none,
|
"restriction": restriction_none,
|
||||||
|
/**
|
||||||
|
* @todo heed stuff.input
|
||||||
|
*/
|
||||||
"execution": async (stuff) => {
|
"execution": async (stuff) => {
|
||||||
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
|
const user_id : (null | type_user_id) = await _zeitbild.api.web_auth(
|
||||||
stuff.headers["Authorization"]
|
stuff.headers["Authorization"]
|
||||||
|
@ -70,9 +73,21 @@ namespace _zeitbild.api
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (stuff.input === null) {
|
||||||
|
return Promise.resolve(
|
||||||
|
{
|
||||||
|
"status_code": 400,
|
||||||
|
"data": null,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return (
|
return (
|
||||||
_zeitbild.service.caldav.projects(user_id)
|
_zeitbild.service.caldav.projects(
|
||||||
|
stuff.input,
|
||||||
|
user_id
|
||||||
|
)
|
||||||
.then(
|
.then(
|
||||||
(output) => Promise.resolve(
|
(output) => Promise.resolve(
|
||||||
{
|
{
|
||||||
|
@ -85,6 +100,7 @@ namespace _zeitbild.api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,9 @@ namespace _zeitbild.conf
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
/**
|
||||||
|
* @todo make mandatory
|
||||||
|
*/
|
||||||
"auth_salt": {
|
"auth_salt": {
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace _zeitbild.service.caldav
|
||||||
string,
|
string,
|
||||||
lib_plankton.webdav.type_data_prop_value
|
lib_plankton.webdav.type_data_prop_value
|
||||||
> = {
|
> = {
|
||||||
// webdav 1
|
// RFC2518
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.2
|
* @see https://datatracker.ietf.org/doc/html/rfc2518#section-13.2
|
||||||
|
@ -125,7 +125,7 @@ namespace _zeitbild.service.caldav
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// webdav 2
|
// RFCP3744
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://datatracker.ietf.org/doc/html/rfc3744#section-4.2
|
* @see https://datatracker.ietf.org/doc/html/rfc3744#section-4.2
|
||||||
|
@ -151,8 +151,15 @@ namespace _zeitbild.service.caldav
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
// caldav
|
// RFC4791
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://datatracker.ietf.org/doc/html/rfc4791#section-5.2.3
|
||||||
|
*/
|
||||||
|
"supported-calendar-component-set": {
|
||||||
|
"kind": "primitive",
|
||||||
|
"data": "VEVENT"
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* @see https://datatracker.ietf.org/doc/html/rfc4791#section-6.2.1
|
* @see https://datatracker.ietf.org/doc/html/rfc4791#section-6.2.1
|
||||||
*/
|
*/
|
||||||
|
@ -161,7 +168,17 @@ namespace _zeitbild.service.caldav
|
||||||
"data": "/caldav/project"
|
"data": "/caldav/project"
|
||||||
},
|
},
|
||||||
|
|
||||||
// WebDAV Current Principal Extension
|
// RFC4918
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://datatracker.ietf.org/doc/html/rfc4918#section-15.6
|
||||||
|
*/
|
||||||
|
"getetag": {
|
||||||
|
"kind": "primitive",
|
||||||
|
"data": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
// RFC5397
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://datatracker.ietf.org/doc/html/rfc5397#section-3
|
* @see https://datatracker.ietf.org/doc/html/rfc5397#section-3
|
||||||
|
@ -171,6 +188,16 @@ namespace _zeitbild.service.caldav
|
||||||
"data": "/caldav"
|
"data": "/caldav"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// RFC6638
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://datatracker.ietf.org/doc/html/rfc6638#section-2.4.1
|
||||||
|
*/
|
||||||
|
"calendar-user-address-set": {
|
||||||
|
"kind": "primitive",
|
||||||
|
"data": ""
|
||||||
|
},
|
||||||
|
|
||||||
// unknown
|
// unknown
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -189,10 +216,6 @@ namespace _zeitbild.service.caldav
|
||||||
"checked-out": {
|
"checked-out": {
|
||||||
"kind": "none",
|
"kind": "none",
|
||||||
"data": null
|
"data": null
|
||||||
},
|
|
||||||
"calendar-user-address-set": {
|
|
||||||
"kind": "none",
|
|
||||||
"data": null
|
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
@ -307,11 +330,75 @@ namespace _zeitbild.service.caldav
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @todo heed input properly
|
||||||
*/
|
*/
|
||||||
export function projects(
|
export function projects(
|
||||||
|
input : lib_plankton.xml.type_node_data,
|
||||||
user_id : type_user_id
|
user_id : type_user_id
|
||||||
) : Promise<lib_plankton.xml.type_node_data>
|
) : Promise<lib_plankton.xml.type_node_data>
|
||||||
{
|
{
|
||||||
|
const answers : Record<
|
||||||
|
string,
|
||||||
|
((stuff : any) => lib_plankton.webdav.type_data_prop_value)
|
||||||
|
> = {
|
||||||
|
"displayname": (stuff) => ({
|
||||||
|
"kind": "primitive",
|
||||||
|
"data": stuff["name"]
|
||||||
|
}),
|
||||||
|
"resourcetype": () => ({
|
||||||
|
"kind": "resourcetype",
|
||||||
|
"data": {
|
||||||
|
"kind": "collection",
|
||||||
|
"type": "calendar",
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @todo remove
|
||||||
|
*/
|
||||||
|
lib_plankton.log.info(
|
||||||
|
"service.caldav.input",
|
||||||
|
input
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @todo check data structure
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
! (
|
||||||
|
(input.kind === "complex")
|
||||||
|
&&
|
||||||
|
(input.data.tag === "propfind")
|
||||||
|
&&
|
||||||
|
(input.data.children.length === 1)
|
||||||
|
&&
|
||||||
|
(input.data.children[0].kind === "complex")
|
||||||
|
&&
|
||||||
|
(input.data.children[0].data.tag === "prop")
|
||||||
|
&&
|
||||||
|
input.data.children[0].data.children.every(
|
||||||
|
node => (node.kind === "complex")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw (new Error("wrong input structure"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const props : Array<string> = (
|
||||||
|
input
|
||||||
|
.data.children
|
||||||
|
[0]
|
||||||
|
.data.children
|
||||||
|
.map(
|
||||||
|
(node) => node.data.tag
|
||||||
|
)
|
||||||
|
);
|
||||||
|
/**
|
||||||
|
* @todo remove
|
||||||
|
*/
|
||||||
|
lib_plankton.log.info(
|
||||||
|
"service.caldav.props",
|
||||||
|
props
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
_zeitbild.service.calendar.overview(user_id)
|
_zeitbild.service.calendar.overview(user_id)
|
||||||
.then(
|
.then(
|
||||||
|
@ -344,6 +431,7 @@ namespace _zeitbild.service.caldav
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"body": {
|
"body": {
|
||||||
|
/*
|
||||||
"propstats": [
|
"propstats": [
|
||||||
{
|
{
|
||||||
"prop": [
|
"prop": [
|
||||||
|
@ -369,6 +457,41 @@ namespace _zeitbild.service.caldav
|
||||||
"description": null,
|
"description": null,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
*/
|
||||||
|
"propstats": props.map(
|
||||||
|
prop => {
|
||||||
|
const prop_parts : Array<string> = prop.toLowerCase().split(":");
|
||||||
|
const prop_normalized : string = ((prop_parts.length <= 1) ? prop_parts[0] : prop_parts.slice(1).join(":"));
|
||||||
|
return (
|
||||||
|
(! (prop_normalized in answers))
|
||||||
|
?
|
||||||
|
{
|
||||||
|
"prop": [
|
||||||
|
{
|
||||||
|
"name": prop,
|
||||||
|
"value": {
|
||||||
|
"kind": "none",
|
||||||
|
"data": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"status": "HTTP/1.1 200 OK",
|
||||||
|
"description": null,
|
||||||
|
}
|
||||||
|
:
|
||||||
|
{
|
||||||
|
"prop": [
|
||||||
|
{
|
||||||
|
"name": prop,
|
||||||
|
"value": answers[prop_normalized](entry),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"status": "HTTP/1.1 404 Not Found",
|
||||||
|
"description": null,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
},
|
},
|
||||||
"description": null,
|
"description": null,
|
||||||
})
|
})
|
||||||
|
@ -382,5 +505,6 @@ namespace _zeitbild.service.caldav
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue