diff --git a/lib/builder.js b/lib/builder.js index 0dee247..f062dbb 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -20,6 +20,7 @@ function ICSFileBuilder() { this.NEWLINE_CHAR = '\r\n'; this.throwError = false; this.ignoreTZIDMismatch = true; + this.busystatus = 'FREE'; } @@ -107,6 +108,7 @@ ICSFileBuilder.prototype.toString = function () { if (_event.description) lines.push('DESCRIPTION:' + _escape(_event.description)); if (_event.url) lines.push('URL;VALUE=URI:' + _event.url); if (_event.status) lines.push('STATUS:' + _event.status.toUpperCase()); + if (_event.busystatus) lines.push('X-MICROSOFT-CDO-BUSYSTATUS:' + _event.busystatus.toUpperCase()) if (_event.organizer) lines.push('ORGANIZER;' + (!!_event.organizer.sentBy ? ('SENT-BY="MAILTO:' + _event.organizer.sentBy + '":') : '') + 'CN="' + _event.organizer.name.replace(/"/g, '\\"') + '":mailto:' + _event.organizer.email); for (var ac = 0; ac < _event.attendees.length; ac++) { if (_event.attendees[ac] instanceof Error) { @@ -184,6 +186,13 @@ ICSFileBuilder.prototype._checkAndBuildEventObject = function (rawEvent) { 'CONFIRMED', 'TENTATIVE', 'CANCELLED' + ], + allowedBusyStatuses = [ + "FREE", + "WORKINGELSEWHERE", + "TENTATIVE", + "BUSY", + "OOF" ]; if (!rawEvent || typeof rawEvent !== 'object') { @@ -325,6 +334,12 @@ ICSFileBuilder.prototype._checkAndBuildEventObject = function (rawEvent) { } event.status = rawEvent.status; + // Busy Status + if (rawEvent.busystatus && allowedBusyStatuses.indexOf(rawEvent.busystatus.toUpperCase()) === -1) { + return new Error('event.busystatus must be one of the following: ' + allowedBusyStatuses.join(', ')); + } + event.busystatus = rawEvent.busystatus; + // URL event.url = rawEvent.url || null;