caldav-adapter 6.0.0 → 6.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "caldav-adapter",
|
|
3
3
|
"description": "CalDAV server for Node.js and Koa. Modernized and maintained for Forward Email.",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.1",
|
|
5
5
|
"author": "Sanders DeNardi and Forward Email LLC",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@xmldom/xmldom": "^0.8.10",
|
|
12
12
|
"basic-auth": "^2.0.1",
|
|
13
|
+
"ical.js": "^1.5.0",
|
|
13
14
|
"lodash": "^4.17.21",
|
|
14
15
|
"moment": "^2.30.1",
|
|
15
16
|
"path-to-regexp": "^6.2.1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const ICAL = require('ical.js');
|
|
1
2
|
const { notFound, preconditionFail } = require('../../../common/x-build');
|
|
2
3
|
const { setMissingMethod } = require('../../../common/response');
|
|
3
4
|
const winston = require('../../../common/winston');
|
|
@@ -12,12 +13,6 @@ module.exports = function (options) {
|
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
if (!ctx.state.params.eventId) {
|
|
16
|
-
log.warn('eventId param not present');
|
|
17
|
-
ctx.body = notFound(ctx.url); // Make more meaningful
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
16
|
if (
|
|
22
17
|
ctx.request.type !== 'text/calendar' ||
|
|
23
18
|
typeof ctx.request.body !== 'string'
|
|
@@ -27,6 +22,31 @@ module.exports = function (options) {
|
|
|
27
22
|
return;
|
|
28
23
|
}
|
|
29
24
|
|
|
25
|
+
if (!ctx.state.params.eventId) {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = ICAL.parse(ctx.request.body);
|
|
28
|
+
if (!parsed || parsed.length === 0) {
|
|
29
|
+
const err = new TypeError('ICAL.parse was not successful');
|
|
30
|
+
err.parsed = parsed;
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const comp = new ICAL.Component(parsed);
|
|
35
|
+
if (!comp) throw new TypeError('ICAL.Component was not successful');
|
|
36
|
+
const vevent = comp.getFirstSubcomponent('vevent');
|
|
37
|
+
if (!vevent)
|
|
38
|
+
throw new TypeError('comp.getFirstSubcomponent was not successful');
|
|
39
|
+
const uid = vevent.getFirstPropertyValue('uid');
|
|
40
|
+
if (!uid || typeof uid !== 'string')
|
|
41
|
+
throw new TypeError('VEVENT missing UID');
|
|
42
|
+
ctx.state.params.eventId = uid;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
log.warn(err);
|
|
45
|
+
ctx.body = notFound(ctx.url); // Make more meaningful
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
const existing = await options.data.getEvent(ctx, {
|
|
31
51
|
eventId: ctx.state.params.eventId,
|
|
32
52
|
principalId: ctx.state.params.principalId,
|