texxasrulez / calendar

GNU Affero General Public License v3.0
14 stars 14 forks source link

Sync does not seem to work? #16

Open hdijkema opened 3 years ago

hdijkema commented 3 years ago

I installed the calendar plugin using composer and ran the post install cmd. When I configure an existing calendar, it doesn't seem to sync it however.

I'm attaching my log.

Any ideas?

console.log

It looks like somehow there's no start and end?

hdijkema commented 3 years ago

It looks like the events aren't properly parsed by libvcalendar? Although it doesn't look wrong to me.

<nmq4plju> caldav_driver: VCal:BEGIN:VCALENDAR
PRODID:-//ownCloud calendar v1.6.3
VERSION:2.0
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:Europe/Amsterdam
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20191114T195031Z
LAST-MODIFIED:20191114T195031Z
DTSTAMP:20191114T195031Z
UID:zccaldav_fa1dfdb7_526c_4bd5_b7a2_f02c4bac7690
SUMMARY: Some appointment
STATUS:CONFIRMED
ORGANIZER;CN=Someone;EMAIL=someone@somesort.org;SCHEDULE-AGENT
 =NONE;SCHEDULE-STATUS=5.3:urn:x-uid:29B6C503-11DF-43EC-8CCA-40C7003149CE
DTSTART:20191122T083050Z
DTEND:20191122T093050Z
LOCATION:Street 7\, City
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
frasersdev commented 3 years ago

I've been able to locate the issue.

the problem is dates are being created as 'DateTimeImmutable' objects but there are various tests for them being a 'DateTime' object - so those tests all fail and the start and end dates get deleted.

I can show thats the problem by changing the tests to Immutable - but this has issues in itself as the plugin is trying to post process the values so its not really a solution...

/libcalendaring/libvcalendar.php line 695 in function _to_array($ve) check for DateTime or DateTimeImmutable

        if ($event['start'] instanceof DateTime || $event['start'] instanceof DateTimeImmutable) {
            $this->_apply_timezone($event['start']);
        }
        else {
            unset($event['start']);
        }
        if ($event['end'] instanceof DateTime || $event['end'] instanceof DateTimeImmutable) {
            $this->_apply_timezone($event['end']);
        }
        else {
            unset($event['end']);
        }

/calendar/drivers/calendar_driver.php line 345 in function validate($event) check for DateTime or DateTimeImmutable

  {
    $valid = true;
    if (!is_object($event['start']) || !(is_a($event['start'], 'DateTime') || is_a($event['start'], 'DateTimeImmutable') ))
      $valid = false;
    if (!is_object($event['end']) || !(is_a($event['end'], 'DateTime') || is_a($event['end'], 'DateTimeImmutable') ))
      $valid = false;
    return $valid;
  }

Goes without saying this is hacky. The object should be mutable if it needs to be mutable. my all day events are coming in wrong and I don't know what other consequences there will be.