fix: Mails are sent to the organizer twice
The `ics` package doesn't support setting the `SCHEDULE-AGENT` parameter, there is a PR (https://github.com/adamgibbons/ics/pull/248), but it is not merged. This is a workaround that relies on the fact that the `ics` package does not properly escape the `name` field of the organizer. In a perfect world, they would merge the PR and create a new release, but this is unfortunately not the world we live in. The `SCHEDULE-AGENT` tells the CalDav server that the invitation has been sent by the client (which is cal in this case), preventing the CalDav server to not send invitations itself. refs #9485pull/11771/head
parent
2faf24fb98
commit
67d38f3a19
|
@ -96,7 +96,13 @@ const getDuration = (start: string, end: string): DurationObject => ({
|
|||
});
|
||||
|
||||
const mapAttendees = (attendees: Person[]): Attendee[] =>
|
||||
attendees.map(({ email, name }) => ({ name, email, partstat: "NEEDS-ACTION" }));
|
||||
// TODO Use `scheduleAgent` once https://github.com/adamgibbons/ics/pull/248 is merged rather
|
||||
// than forcing the value into the partstat string.
|
||||
attendees.map(({ email, name }) => ({
|
||||
name,
|
||||
email,
|
||||
partstat: "NEEDS-ACTION;SCHEDULE-AGENT=CLIENT" as any,
|
||||
}));
|
||||
|
||||
export default abstract class BaseCalendarService implements Calendar {
|
||||
private url = "";
|
||||
|
@ -152,7 +158,10 @@ export default abstract class BaseCalendarService implements Calendar {
|
|||
title: event.title,
|
||||
description: getRichDescription(event),
|
||||
location: getLocation(event),
|
||||
organizer: { email: event.organizer.email, name: event.organizer.name },
|
||||
// TODO Use `name`, `email`, and `scheduleAgent` once https://github.com/adamgibbons/ics/pull/248 is merged
|
||||
organizer: {
|
||||
name: `${event.organizer.name}:MAILTO:${event.organizer.email}:SCHEDULE-AGENT=CLIENT`,
|
||||
},
|
||||
attendees: this.getAttendees(event),
|
||||
/** according to https://datatracker.ietf.org/doc/html/rfc2446#section-3.2.1, in a published iCalendar component.
|
||||
* "Attendees" MUST NOT be present
|
||||
|
@ -228,7 +237,10 @@ export default abstract class BaseCalendarService implements Calendar {
|
|||
title: event.title,
|
||||
description: getRichDescription(event),
|
||||
location: getLocation(event),
|
||||
organizer: { email: event.organizer.email, name: event.organizer.name },
|
||||
// TODO Use `name`, `email`, and `scheduleAgent` once https://github.com/adamgibbons/ics/pull/248 is merged
|
||||
organizer: {
|
||||
name: `${event.organizer.name}:MAILTO:${event.organizer.email}:SCHEDULE-AGENT=CLIENT`,
|
||||
},
|
||||
attendees: this.getAttendees(event),
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue