adds custom filter allowing eml format (#4815)

pull/4806/head^2
Syed Ali Shahbaz 2022-10-04 11:02:28 +02:00 committed by GitHub
parent 4438ca2a63
commit 369d7c4e28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -221,6 +221,20 @@ export default abstract class BaseCalendarService implements Calendar {
}
}
isValidFormat = (url: string): boolean => {
const acceptedFormats = ["eml", "ics"];
const urlFormat = url.split(".").pop();
if (urlFormat === undefined) {
console.error("Invalid request, calendar object extension missing");
return false;
}
if (!acceptedFormats.includes(urlFormat)) {
console.error(`Unsupported calendar object format: ${urlFormat}`);
return false;
}
return true;
};
async getAvailability(
dateFrom: string,
dateTo: string,
@ -232,6 +246,7 @@ export default abstract class BaseCalendarService implements Calendar {
.filter((sc) => ["caldav_calendar", "apple_calendar"].includes(sc.integration ?? ""))
.map((sc) =>
fetchCalendarObjects({
urlFilter: (url: string) => this.isValidFormat(url),
calendar: {
url: sc.externalId,
},