[CalendarServer-changes] [15503] CalendarServer/trunk/txdav/caldav/datastore

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 11 11:08:43 PDT 2016


Revision: 15503
          http://trac.calendarserver.org//changeset/15503
Author:   cdaboo at apple.com
Date:     2016-04-11 11:08:43 -0700 (Mon, 11 Apr 2016)
Log Message:
-----------
Don't do splitter if organizer is not valid.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/sql.py
    CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py	2016-04-06 20:23:31 UTC (rev 15502)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py	2016-04-11 18:08:43 UTC (rev 15503)
@@ -5192,8 +5192,29 @@
         """
 
         splitter = iCalSplitter(config.Scheduling.Options.Splitting.Size, config.Scheduling.Options.Splitting.PastDays)
-        ical = (yield self.component())
-        will_split, _ignore_fullyInFuture = splitter.willSplit(ical)
+        component = (yield self.component())
+
+        # Do some sanity checks first
+
+        # Organizer either missing or must be valid
+        organizer = component.getOrganizer()
+        if organizer is not None:
+            # Must be valid for scheduling
+            organizerAddress = (yield calendarUserFromCalendarUserAddress(organizer, self._txn))
+            if organizerAddress is None:
+                returnValue(False)
+
+            if organizerAddress.hosted():
+                # Must be enabled and organizer
+                if not organizerAddress.record.enabledAsOrganizer():
+                    returnValue(False)
+
+                # Cannot be the attendee
+                if organizerAddress.record.uid != self.calendar().ownerHome().uid():
+                    returnValue(False)
+
+
+        will_split, _ignore_fullyInFuture = splitter.willSplit(component)
         returnValue(will_split)
 
 

Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2016-04-06 20:23:31 UTC (rev 15502)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py	2016-04-11 18:08:43 UTC (rev 15503)
@@ -5039,9 +5039,9 @@
 
 
     @inlineCallbacks
-    def test_calendarObjectSplit_no_non_organizer_split(self):
+    def test_calendarObjectSplit_no_split_small_size(self):
         """
-        Test that calendar objects do not split on attendee change.
+        Test that calendar objects do not split when the size is below the threshold.
         """
         self.patch(config.Scheduling.Options.Splitting, "Enabled", True)
         self.patch(config.Scheduling.Options.Splitting, "Size", 1024)
@@ -5106,6 +5106,83 @@
 
 
     @inlineCallbacks
+    def test_calendarObjectSplit_no_split_disabled_organizer(self):
+        """
+        Test that calendar objects do not split when the organizer is not enabled.
+        """
+        self.patch(config.Scheduling.Options.Splitting, "Enabled", False)
+        self.patch(config.Scheduling.Options.Splitting, "Size", 1024)
+        self.patch(config.Scheduling.Options.Splitting, "PastDays", 14)
+        self.patch(config.Scheduling.Options.Splitting, "Delay", 2)
+
+        # Create one event that will not split
+        calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+
+        data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:%(now_back28)s
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY;COUNT=50
+SUMMARY:1234567890123456789012345678901234567890
+ 1234567890123456789012345678901234567890
+ 1234567890123456789012345678901234567890
+ 1234567890123456789012345678901234567890
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_back25)s
+DTSTART:%(now_back25)s
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01 at example.com
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_back24)s
+DTSTART:%(now_back24)s
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01 at example.com
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_fwd10)s
+DTSTART:%(now_fwd10)s
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+        # See if it will split
+        component = Component.fromString(data % self.dtsubs)
+        cobj = yield calendar.createCalendarObjectWithName("data1.ics", component)
+        self.assertFalse(hasattr(cobj, "_workItems"))
+        yield self.commit()
+
+        # Enable splitting and make sure it won't split
+        self.patch(config.Scheduling.Options.Splitting, "Enabled", True)
+        cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="user01")
+        yield self.removeRecord(u"user01")
+        willSplit = yield cobj.willSplit()
+        self.assertFalse(willSplit)
+
+
+    @inlineCallbacks
     def test_calendarObjectSplit_attachments(self):
         """
         Test that splitting of calendar objects with managed attachments works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160411/ba53bb85/attachment.html>


More information about the calendarserver-changes mailing list