caldav-adapter 6.0.1 → 7.0.0
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": "
|
|
4
|
+
"version": "7.0.0",
|
|
5
5
|
"author": "Sanders DeNardi and Forward Email LLC",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@xmldom/xmldom": "^0.8.10",
|
|
12
12
|
"basic-auth": "^2.0.1",
|
|
13
|
-
"ical.js": "^1.5.0",
|
|
14
13
|
"lodash": "^4.17.21",
|
|
15
14
|
"moment": "^2.30.1",
|
|
16
15
|
"path-to-regexp": "^6.2.1",
|
|
@@ -5,6 +5,17 @@ module.exports = function (options) {
|
|
|
5
5
|
const log = winston({ ...options, label: 'calendar/get' });
|
|
6
6
|
|
|
7
7
|
const exec = async function (ctx, calendar) {
|
|
8
|
+
if (!ctx.state.params.eventId) {
|
|
9
|
+
const events = await options.data.getEventsForCalendar(ctx, {
|
|
10
|
+
principalId: ctx.state.params.principalId,
|
|
11
|
+
calendarId: options.data.getCalendarId(ctx, calendar),
|
|
12
|
+
user: ctx.state.user,
|
|
13
|
+
fullData: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return options.data.buildICS(ctx, events, calendar);
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
const event = await options.data.getEvent(ctx, {
|
|
9
20
|
eventId: ctx.state.params.eventId,
|
|
10
21
|
principalId: ctx.state.params.principalId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const { notFound, preconditionFail } = require('../../../common/x-build');
|
|
1
|
+
const { notFound } = require('../../../common/x-build');
|
|
2
|
+
// const { notFound, preconditionFail } = require('../../../common/x-build');
|
|
3
3
|
const { setMissingMethod } = require('../../../common/response');
|
|
4
4
|
const winston = require('../../../common/winston');
|
|
5
5
|
|
|
@@ -17,34 +17,24 @@ module.exports = function (options) {
|
|
|
17
17
|
ctx.request.type !== 'text/calendar' ||
|
|
18
18
|
typeof ctx.request.body !== 'string'
|
|
19
19
|
) {
|
|
20
|
-
log.warn('incoming
|
|
20
|
+
log.warn('incoming ICS file not present in body');
|
|
21
21
|
ctx.body = notFound(ctx.url); // Make more meaningful
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
//
|
|
26
|
+
// NOTE: if there is no `eventId` then it is updating the entire VCALENDAR
|
|
27
|
+
//
|
|
25
28
|
if (!ctx.state.params.eventId) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
}
|
|
29
|
+
const updatedCalendar = await options.data.updateCalendar(ctx, {
|
|
30
|
+
principalId: ctx.state.params.principalId,
|
|
31
|
+
calendarId: ctx.state.params.calendarId,
|
|
32
|
+
user: ctx.state.user
|
|
33
|
+
});
|
|
34
|
+
/* https://tools.ietf.org/html/rfc4791#section-5.3.2 */
|
|
35
|
+
ctx.status = 201;
|
|
36
|
+
ctx.set('ETag', options.data.getETag(ctx, updatedCalendar));
|
|
37
|
+
return;
|
|
48
38
|
}
|
|
49
39
|
|
|
50
40
|
const existing = await options.data.getEvent(ctx, {
|
|
@@ -57,12 +47,14 @@ module.exports = function (options) {
|
|
|
57
47
|
log.debug(`existing event${existing ? '' : ' not'} found`);
|
|
58
48
|
|
|
59
49
|
if (existing) {
|
|
50
|
+
/*
|
|
60
51
|
if (ctx.get('if-none-match') === '*') {
|
|
61
52
|
log.warn('if-none-match: * header present, precondition failed');
|
|
62
53
|
ctx.status = 412;
|
|
63
54
|
ctx.body = preconditionFail(ctx.url, 'no-uid-conflict');
|
|
64
55
|
return;
|
|
65
56
|
}
|
|
57
|
+
*/
|
|
66
58
|
|
|
67
59
|
const updateObject = await options.data.updateEvent(ctx, {
|
|
68
60
|
eventId: ctx.state.params.eventId,
|