caldav-adapter 8.2.7 → 8.2.9

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.7",
4
+ "version": "8.2.9",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -39,26 +39,29 @@ module.exports = function (options) {
39
39
 
40
40
  const ics = await options.data.buildICS(ctx, events, calendar);
41
41
 
42
- const accept = ctx.accepts(['text/xml', 'text/calendar']);
43
-
44
- if (accept === 'text/xml') {
45
- const responseObj = response(ctx.url, status[200], [
46
- {
47
- 'D:getetag': options.data.getETag(ctx, calendar)
48
- },
49
- {
50
- 'CAL:calendar-data': encodeXMLEntities(ics)
51
- }
52
- ]);
53
- return build(multistatus([responseObj]));
42
+ if (
43
+ ctx.accepts('text/calendar') ||
44
+ ctx.accepts('application/ics') ||
45
+ ctx.accepts('text/x-vcalendar') ||
46
+ ctx.accepts('application/octet-stream')
47
+ ) {
48
+ ctx.status = 200;
49
+ ctx.remove('DAV');
50
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
51
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
52
+ return ics;
54
53
  }
55
54
 
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));
61
- return ics;
55
+ // xml
56
+ const responseObj = response(ctx.url, status[200], [
57
+ {
58
+ 'D:getetag': options.data.getETag(ctx, calendar)
59
+ },
60
+ {
61
+ 'CAL:calendar-data': encodeXMLEntities(ics)
62
+ }
63
+ ]);
64
+ return build(multistatus([responseObj]));
62
65
  }
63
66
 
64
67
  const event = await options.data.getEvent(ctx, {
@@ -76,26 +79,28 @@ module.exports = function (options) {
76
79
 
77
80
  const ics = await options.data.buildICS(ctx, event, calendar);
78
81
 
79
- const accept = ctx.accepts(['text/xml', 'text/calendar']);
80
-
81
- if (accept === 'text/xml') {
82
- const responseObj = response(ctx.url, status[200], [
83
- {
84
- 'D:getetag': options.data.getETag(ctx, calendar)
85
- },
86
- {
87
- 'CAL:calendar-data': encodeXMLEntities(ics)
88
- }
89
- ]);
90
- return build(multistatus([responseObj]));
82
+ if (
83
+ ctx.accepts('text/calendar') ||
84
+ ctx.accepts('application/ics') ||
85
+ ctx.accepts('text/x-vcalendar') ||
86
+ ctx.accepts('application/octet-stream')
87
+ ) {
88
+ ctx.status = 200;
89
+ ctx.remove('DAV');
90
+ ctx.set('Content-Type', 'text/calendar; charset=utf-8');
91
+ ctx.set('ETag', options.data.getETag(ctx, calendar));
92
+ return ics;
91
93
  }
92
94
 
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));
98
- return ics;
95
+ const responseObj = response(ctx.url, status[200], [
96
+ {
97
+ 'D:getetag': options.data.getETag(ctx, calendar)
98
+ },
99
+ {
100
+ 'CAL:calendar-data': encodeXMLEntities(ics)
101
+ }
102
+ ]);
103
+ return build(multistatus([responseObj]));
99
104
  };
100
105
 
101
106
  return {