[CalendarServer-changes] [15779] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Wed Jul 27 14:50:59 PDT 2016


Revision: 15779
          http://trac.calendarserver.org//changeset/15779
Author:   sagen at apple.com
Date:     2016-07-27 14:50:59 -0700 (Wed, 27 Jul 2016)
Log Message:
-----------
Adds a method on Component to repair missing datestamp parameters from comment properties.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2016-07-27 21:46:54 UTC (rev 15778)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2016-07-27 21:50:59 UTC (rev 15779)
@@ -3812,7 +3812,24 @@
         return False
 
 
+    def repairMissingDatestampsFromComments(self):
+        """
+        Some clients are leaving out the datestamp from comments; this method
+        adds this parameter where it's missing (using a value of now in UTC)
+        """
+        if self.name() == "VCALENDAR":
+            for component in self.subcomponents():
+                if component.name() in ("VTIMEZONE",):
+                    continue
+                component.repairMissingDatestampsFromComments()
 
+        else:
+            for prop in tuple(self.properties(ATTENDEE_COMMENT)):
+                if not prop.hasParameter(DTSTAMP_PARAM):
+                    prop.setParameter(DTSTAMP_PARAM, DateTime.getNowUTC().getText())
+
+
+
 # #
 # Timezones
 # #

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2016-07-27 21:46:54 UTC (rev 15778)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2016-07-27 21:50:59 UTC (rev 15779)
@@ -12187,3 +12187,31 @@
         cal = Component.fromString(data)
         self.assertTrue(cal is not None)
         self.assertTrue(cal.mainComponent().hasProperty("GEO"))
+
+
+    def test_missingCommentDatestamp(self):
+
+        """
+        Verify attendee comments missing date stamps are repaired
+        """
+
+        data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DURATION:PT1H
+DTSTAMP:20080601T120000Z
+RRULE:FREQ=DAILY
+SUMMARY:Test
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:user01":Message1
+X-CALENDARSERVER-ATTENDEE-COMMENT;X-CALENDARSERVER-ATTENDEE-REF="urn:uuid:user02":Message2
+END:VEVENT
+END:VCALENDAR
+"""
+
+        cal = Component.fromString(data)
+        cal.repairMissingDatestampsFromComments()
+        for prop in list(cal.mainComponent().properties("X-CALENDARSERVER-ATTENDEE-COMMENT")):
+            self.assertTrue(prop.hasParameter("X-CALENDARSERVER-DTSTAMP"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160727/d1de7a6d/attachment.html>


More information about the calendarserver-changes mailing list