Fixed nextcloud & fastmail events not created (#1300)

* fixed nextcloud

* fixed nextcloud & fastmail issues
This commit is contained in:
Nathaniel 2021-12-13 21:58:09 +08:00 committed by GitHub
parent 357e279dd8
commit 43c939e342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,7 +76,8 @@ export class BaseCalendarApiAdapter {
description: getRichDescription(event),
location: getLocation(event),
organizer: { email: event.organizer.email, name: event.organizer.name },
attendees: this.getAttendees(event.attendees),
// according to https://datatracker.ietf.org/doc/html/rfc2446#section-3.2.1, in a published iCalendar component. "Attendees" MUST NOT be present
// attendees: this.getAttendees(event.attendees),
});
if (error) throw new Error("Error creating iCalString");
@ -84,7 +85,7 @@ export class BaseCalendarApiAdapter {
if (!iCalString) throw new Error("Error creating iCalString");
/** We create the event directly on iCal */
await Promise.all(
const responses = await Promise.all(
calendars
.filter((c) =>
event.destinationCalendar?.externalId
@ -97,12 +98,19 @@ export class BaseCalendarApiAdapter {
url: calendar.externalId,
},
filename: `${uid}.ics`,
iCalString,
// according to https://datatracker.ietf.org/doc/html/rfc4791#section-4.1, Calendar object resources contained in calendar collections MUST NOT specify the iCalendar METHOD property.
iCalString: iCalString.replace(/METHOD:[^\r\n]+\r\n/g, ""),
headers: this.headers,
})
)
);
if (responses.some((r) => !r.ok)) {
throw new Error(
`Error creating event: ${(await Promise.all(responses.map((r) => r.text()))).join(", ")}`
);
}
return {
uid,
id: uid,