Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_loadCalendar() {
// TODO: Make use of HTTP cache control stuff
this.log(`Updating calendar ${this.name}`);
ical.fromURL(this._url, {}, (err, cal) => {
if (err) {
this.log(`Failed to load iCal calender: ${this.url} with error ${err}`);
this.emit('error', err);
}
if (cal) {
this.emit('data', cal);
}
this._scheduleNextIteration();
});
}
if (message[1] === ' ') {
message = message.replace(' ', '')
}
message = message.split(' ')
const cmd = message[0]
let localHashtag = ''
if (message.length > 1) {
localHashtag = message[1].toLowerCase()
}
const user = event.getSender()
const roomId = room.roomId
if (cmd === '!calendar' || cmd === '!cal') {
if (localHashtag.length == 0 && hashtagMappings.hasOwnProperty(roomId)) {
localHashtag = hashtagMappings[roomId]
}
ical.fromURL(calendarURL, {}, function(err, data) {
if (!err) {
const today = new Date()
const upperLimit = new Date()
upperLimit.setDate(today.getDate() + calendarUpperLimitInMonths * 30)
const globalFormattingOptions = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
}
globals = []
locals = []
for (var key in data) {
if (data.hasOwnProperty(key) && data[key].start && data[key].end) {
if (data[key].rrule && data[key].start.tz) {
var nextOccurrences = data[key].rrule.between(
for (let calendarObject of calendarEntry.calendar.objects) {
if (calendarObject.data && calendarObject.data.href) {
let ics = url.origin + calendarObject.data.href;
let header = {};
let username = node.config.username;
let password = node.config.password;
if (username && password) {
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
header = {
headers: {
'Authorization': auth
}
}
}
return ical.fromURL(ics, header).then(data => {
for (var k in data) {
var ev = data[k];
ev.calendarName = calendar.displayName;
retEntries[ev.uid] = ev;
}
return retEntries;
});
}
}
}
}
})
);
for (var _a = 0, _b = calendarEntry.calendar.objects; _a < _b.length; _a++) {
var calendarObject = _b[_a];
if (calendarObject.data && calendarObject.data.href) {
var ics = url.origin + calendarObject.data.href;
var header = {};
var username = node.config.username;
var password = node.config.password;
if (username && password) {
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
header = {
headers: {
'Authorization': auth
}
};
}
return ical.fromURL(ics, header).then(function (data) {
for (var k in data) {
var ev = data[k];
ev.calendarName = calendar.displayName;
retEntries[ev.uid] = ev;
}
return retEntries;
});
}
}
}
}
}));
}
});
}
else {
if (urlOrFile.match(/^https?:\/\//)) {
var header = {};
var username = node.config.username;
var password = node.config.password;
if (username && password) {
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
header = {
headers: {
'Authorization': auth
}
};
}
ical.fromURL(node.config.url, header, function (err, data) {
if (err) {
callback && callback(err, null);
return;
}
callback && callback(null, data);
});
}
else {
ical.parseFile(node.config.url, function (err, data) {
if (err) {
callback && callback(err, null);
return;
}
callback && callback(null, data);
});
}
} else {
if (urlOrFile.match(/^https?:\/\//)) {
let header = {};
let username = node.config.username;
let password = node.config.password;
if (username && password) {
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
header = {
headers: {
'Authorization': auth
}
}
}
ical.fromURL(node.config.url, header, (err, data) => {
if (err) {
callback && callback(err, null);
return;
}
callback && callback(null, data);
});
} else {
ical.parseFile(node.config.url, (err, data) => {
if (err) {
callback && callback(err, null);
return;
}
callback && callback(null, data);
});
}
}