caldav-adapter 6.0.0 → 6.1.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": "6.
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"author": "Sanders DeNardi and Forward Email LLC",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
|
|
@@ -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,
|
|
@@ -12,21 +12,30 @@ module.exports = function (options) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
|
|
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
15
|
if (
|
|
22
16
|
ctx.request.type !== 'text/calendar' ||
|
|
23
17
|
typeof ctx.request.body !== 'string'
|
|
24
18
|
) {
|
|
25
|
-
log.warn('incoming
|
|
19
|
+
log.warn('incoming ICS file not present in body');
|
|
26
20
|
ctx.body = notFound(ctx.url); // Make more meaningful
|
|
27
21
|
return;
|
|
28
22
|
}
|
|
29
23
|
|
|
24
|
+
//
|
|
25
|
+
// NOTE: if there is no `eventId` then it is updating the entire VCALENDAR
|
|
26
|
+
//
|
|
27
|
+
if (!ctx.state.params.eventId) {
|
|
28
|
+
const updatedCalendar = await options.data.updateCalendar(ctx, {
|
|
29
|
+
principalId: ctx.state.params.principalId,
|
|
30
|
+
calendarId: ctx.state.params.calendarId,
|
|
31
|
+
user: ctx.state.user
|
|
32
|
+
});
|
|
33
|
+
/* https://tools.ietf.org/html/rfc4791#section-5.3.2 */
|
|
34
|
+
ctx.status = 201;
|
|
35
|
+
ctx.set('ETag', options.data.getETag(ctx, updatedCalendar));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
const existing = await options.data.getEvent(ctx, {
|
|
31
40
|
eventId: ctx.state.params.eventId,
|
|
32
41
|
principalId: ctx.state.params.principalId,
|