caldav-adapter 8.2.5 → 8.2.7

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": "8.2.5",
4
+ "version": "8.2.7",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -1,6 +1,11 @@
1
1
  const { setMissingMethod } = require('../../../common/response');
2
2
  const winston = require('../../../common/winston');
3
- const { response, status } = require('../../../common/x-build');
3
+ const {
4
+ response,
5
+ status,
6
+ build,
7
+ multistatus
8
+ } = require('../../../common/x-build');
4
9
 
5
10
  /**
6
11
  * Encode special characters for XML content to prevent parsing errors
@@ -37,7 +42,7 @@ module.exports = function (options) {
37
42
  const accept = ctx.accepts(['text/xml', 'text/calendar']);
38
43
 
39
44
  if (accept === 'text/xml') {
40
- return response(ctx.url, status[200], [
45
+ const responseObj = response(ctx.url, status[200], [
41
46
  {
42
47
  'D:getetag': options.data.getETag(ctx, calendar)
43
48
  },
@@ -45,12 +50,14 @@ module.exports = function (options) {
45
50
  'CAL:calendar-data': encodeXMLEntities(ics)
46
51
  }
47
52
  ]);
53
+ return build(multistatus([responseObj]));
48
54
  }
49
55
 
50
- // text/calendar
51
- // application/ics
52
- // text/x-vcalendar
53
- // application/octet-stream
56
+ // Return raw iCalendar with proper headers
57
+ ctx.status = 200;
58
+ ctx.remove('DAV');
59
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
60
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
54
61
  return ics;
55
62
  }
56
63
 
@@ -72,22 +79,22 @@ module.exports = function (options) {
72
79
  const accept = ctx.accepts(['text/xml', 'text/calendar']);
73
80
 
74
81
  if (accept === 'text/xml') {
75
- return response(ctx.url, status[200], [
82
+ const responseObj = response(ctx.url, status[200], [
76
83
  {
77
- // TODO: should E-Tag here be of calendar or event?
78
- // 'D:getetag': options.data.getETag(ctx, calendar)
79
84
  'D:getetag': options.data.getETag(ctx, calendar)
80
85
  },
81
86
  {
82
87
  'CAL:calendar-data': encodeXMLEntities(ics)
83
88
  }
84
89
  ]);
90
+ return build(multistatus([responseObj]));
85
91
  }
86
92
 
87
- // text/calendar
88
- // application/ics
89
- // text/x-vcalendar
90
- // application/octet-stream
93
+ // Return raw iCalendar with proper headers
94
+ ctx.status = 200;
95
+ ctx.remove('DAV');
96
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
97
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
91
98
  return ics;
92
99
  };
93
100