caldav-adapter 8.2.4 → 8.2.5

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.4",
4
+ "version": "8.2.5",
5
5
  "author": "Sanders DeNardi and Forward Email LLC",
6
6
  "contributors": [
7
7
  "Sanders DeNardi <sedenardi@gmail.com> (http://www.sandersdenardi.com/)",
@@ -32,18 +32,26 @@ module.exports = function (options) {
32
32
  fullData: true
33
33
  });
34
34
 
35
- if (ctx.accepts('text/calendar'))
36
- return options.data.buildICS(ctx, events, calendar);
37
-
38
35
  const ics = await options.data.buildICS(ctx, events, calendar);
39
- return response(ctx.url, status[200], [
40
- {
41
- 'D:getetag': options.data.getETag(ctx, calendar)
42
- },
43
- {
44
- 'CAL:calendar-data': encodeXMLEntities(ics)
45
- }
46
- ]);
36
+
37
+ const accept = ctx.accepts(['text/xml', 'text/calendar']);
38
+
39
+ if (accept === 'text/xml') {
40
+ return response(ctx.url, status[200], [
41
+ {
42
+ 'D:getetag': options.data.getETag(ctx, calendar)
43
+ },
44
+ {
45
+ 'CAL:calendar-data': encodeXMLEntities(ics)
46
+ }
47
+ ]);
48
+ }
49
+
50
+ // text/calendar
51
+ // application/ics
52
+ // text/x-vcalendar
53
+ // application/octet-stream
54
+ return ics;
47
55
  }
48
56
 
49
57
  const event = await options.data.getEvent(ctx, {
@@ -59,20 +67,28 @@ module.exports = function (options) {
59
67
  return;
60
68
  }
61
69
 
62
- if (ctx.accepts('text/calendar'))
63
- return options.data.buildICS(ctx, event, calendar);
64
-
65
70
  const ics = await options.data.buildICS(ctx, event, calendar);
66
- return response(ctx.url, status[200], [
67
- {
68
- // TODO: should E-Tag here be of calendar or event?
69
- // 'D:getetag': options.data.getETag(ctx, calendar)
70
- 'D:getetag': options.data.getETag(ctx, calendar)
71
- },
72
- {
73
- 'CAL:calendar-data': encodeXMLEntities(ics)
74
- }
75
- ]);
71
+
72
+ const accept = ctx.accepts(['text/xml', 'text/calendar']);
73
+
74
+ if (accept === 'text/xml') {
75
+ return response(ctx.url, status[200], [
76
+ {
77
+ // TODO: should E-Tag here be of calendar or event?
78
+ // 'D:getetag': options.data.getETag(ctx, calendar)
79
+ 'D:getetag': options.data.getETag(ctx, calendar)
80
+ },
81
+ {
82
+ 'CAL:calendar-data': encodeXMLEntities(ics)
83
+ }
84
+ ]);
85
+ }
86
+
87
+ // text/calendar
88
+ // application/ics
89
+ // text/x-vcalendar
90
+ // application/octet-stream
91
+ return ics;
76
92
  };
77
93
 
78
94
  return {