caldav-adapter 8.1.0 → 8.2.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/common/x-build.js CHANGED
@@ -62,8 +62,13 @@ const status = {
62
62
  };
63
63
  module.exports.status = status;
64
64
 
65
- function response(url, status, props) {
65
+ function response(url, status, props, deleted) {
66
66
  const res = href(url);
67
+ if (deleted) {
68
+ res[buildTag('DAV:', 'status')] = status;
69
+ return res;
70
+ }
71
+
67
72
  res[buildTag('DAV:', 'propstat')] = [
68
73
  {
69
74
  [buildTag('DAV:', 'status')]: status
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": "8.1.0",
4
+ "version": "8.2.1",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -29,7 +29,10 @@ module.exports = function (options) {
29
29
  });
30
30
  }
31
31
 
32
- ctx.status = 200;
32
+ // fix header otherwise it's got a multi-status response
33
+ // (e.g. since we call `setMultistatusResponse` before exec())
34
+ ctx.set('Content-Type', 'text/html; charset="utf-8"');
35
+ ctx.status = 204; // no content
33
36
  ctx.body = '';
34
37
  };
35
38
 
@@ -22,9 +22,27 @@ module.exports = function (options) {
22
22
  event
23
23
  });
24
24
  });
25
+
26
+ //
27
+ // <https://www.rfc-editor.org/rfc/rfc6578.html#page-14:~:text=The%20content%20of%20each%20DAV%3Aresponse%20element%20differs%20depending%20on%20how%0A%20%20%20%20%20%20the%20member%20was%20altered%3A>
28
+ //
29
+ // > For members that have changed (i.e., are new or have had their
30
+ // mapped resource modified), the DAV:response MUST contain at
31
+ // least one DAV:propstat element and MUST NOT contain any
32
+ // DAV:status element.
33
+
34
+ // > For members that have been removed, the DAV:response MUST
35
+ // contain one DAV:status with a value set to '404 Not Found' and
36
+ // MUST NOT contain any DAV:propstat element.
37
+ //
25
38
  const pRes = await Promise.all(propActions);
26
39
  const url = path.join(ctx.url, `${event.eventId}.ics`);
27
- const resp = response(url, status[200], _.compact(pRes));
40
+ const resp = event.deleted_at
41
+ ? response(url, status[404], [], true)
42
+ : response(url, status[200], _.compact(pRes));
43
+
44
+ // TODO: misses is not used and this condition never occurs
45
+ // (artifact from old codebase)
28
46
  if (misses.length > 0) {
29
47
  resp['D:propstat'].push(missingPropstats(misses));
30
48
  }
@@ -19,11 +19,13 @@ module.exports = function (options) {
19
19
  const fullData = _.some(children, (child) => {
20
20
  return child.localName === 'calendar-data';
21
21
  });
22
+
22
23
  const events = await options.data.getEventsForCalendar(ctx, {
23
24
  principalId: ctx.state.params.principalId,
24
25
  calendarId: options.data.getCalendarId(ctx, calendar),
25
26
  user: ctx.state.user,
26
- fullData
27
+ fullData,
28
+ showDeleted: true
27
29
  });
28
30
  const { responses } = await eventResponse(ctx, events, calendar, children);
29
31