sabre-io / Baikal

Baïkal is a Calendar+Contacts server
https://sabre.io/baikal/
GNU General Public License v3.0
2.53k stars 290 forks source link

not supported calendar message.ics #1305

Open warfriet opened 1 week ago

warfriet commented 1 week ago

Baikal version: 0.10.1

Expected behaviour: When I invite a person via email the ics file is not supported with MS Outlook.

I have changed the CalendarObject.php at the put(): public function put($calendarData) { if (is_resource($calendarData)) { $calendarData = stream_get_contents($calendarData); }

// Ensure event data begins with BEGIN:VEVENT
if (strpos($calendarData, "BEGIN:VEVENT") !== false) {
    $eventStartPos = strpos($calendarData, "BEGIN:VEVENT") + strlen("BEGIN:VEVENT\n");

    // Insert UID if missing
    if (strpos($calendarData, 'UID:') === false) {
        $uid = "UID:" . uniqid() . "@example.com\n";
        $calendarData = substr_replace($calendarData, $uid, $eventStartPos, 0);
    }

    // Insert SUMMARY if missing
    if (strpos($calendarData, 'SUMMARY:') === false) {
        $summary = "SUMMARY:Untitled Event\n";
        $calendarData = substr_replace($calendarData, $summary, $eventStartPos, 0);
    }
}

// Fold long lines
$lines = explode("\n", $calendarData);
foreach ($lines as &$line) {
    if (strlen($line) > 75) {
        $line = foldLine($line);
    }
}
$calendarData = implode("\n", $lines);

// Update the calendar object in the backend
$etag = $this->caldavBackend->updateCalendarObject(
    $this->calendarInfo['id'],
    $this->objectData['uri'],
    $calendarData
);

$this->objectData['calendardata'] = $calendarData;
$this->objectData['etag'] = $etag;

return $etag;

}

Current behaviour: When received in MS Outlook the file is marked as not supported calendar message.ics Looks if Baikal does not make an correct ics file. This is in the ics file: ATTENDEE;CN=Person Company;PARTSTAT=NEEDS-ACTION;CUTYPE=INDIVIDUAL; ROLE=REQ-PARTICIPANT:mailto:hangloose@Company.com ATTENDEE;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL; ROLE=REQ-PARTICIPANT:mailto:Person@ezeb.net DTSTART;TZID=Europe/Berlin:20241116T113000 DTEND;TZID=Europe/Berlin:20241116T133000 TRANSP:OPAQUE LOCATION:https://myn.nl/trainingen/myn-academy-get-the-cake X-MOZ-GENERATION:3 SEQUENCE:2 DTSTAMP:20241114T161806Z BEGIN:VALARM ACTION:DISPLAY TRIGGER:PT0S DESCRIPTION:Default Mozilla Description END:VALARM END:VEVENT END:VCALENDAR

Is this a common bug? Can it be fixed?