[CalendarServer-changes] [10847] CalendarServer/trunk/twistedcaldav/scheduling/processing.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 5 10:52:12 PST 2013
Revision: 10847
http://trac.calendarserver.org//changeset/10847
Author: cdaboo at apple.com
Date: 2013-03-05 10:52:12 -0800 (Tue, 05 Mar 2013)
Log Message:
-----------
Don't auto-accept process instances in the past.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/scheduling/processing.py
Modified: CalendarServer/trunk/twistedcaldav/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2013-03-05 18:50:34 UTC (rev 10846)
+++ CalendarServer/trunk/twistedcaldav/scheduling/processing.py 2013-03-05 18:52:12 UTC (rev 10847)
@@ -766,13 +766,28 @@
expand_max = PyCalendarDateTime.getToday() + default_future_expansion_duration
instances = calendar.expandTimeRanges(expand_max, ignoreInvalidInstances=True)
+ # We are goin g to ignore auto-accept processing for anything more than a day old (actually use -2 days
+ # to add some slop to account for possible timezone offsets)
+ min_date = PyCalendarDateTime.getToday()
+ min_date.offsetDay(-2)
+ allOld = True
+
# Cache the current attendee partstat on the instance object for later use, and
# also mark whether the instance time slot would be free
for instance in instances.instances.itervalues():
attendee = instance.component.getAttendeeProperty(cuas)
instance.partstat = attendee.parameterValue("PARTSTAT", "NEEDS-ACTION") if attendee else None
instance.free = True
+ instance.active = (instance.end > min_date)
+ if instance.active:
+ allOld = False
+ # If every instance is in the past we punt right here so we don't waste time on freebusy lookups etc.
+ # There will be no auto-accept and no inbox item stored (so as not to waste storage on items that will
+ # never be processed).
+ if allOld:
+ returnValue((False, False, "",))
+
# Extract UID from primary component as we want to ignore this one if we match it
# in any calendars.
comp = calendar.mainComponent(allow_multiple=True)
@@ -796,7 +811,7 @@
# Now do search for overlapping time-range and set instance.free based
# on whether there is an overlap or not
for instance in instances.instances.itervalues():
- if instance.partstat == "NEEDS-ACTION" and instance.free:
+ if instance.partstat == "NEEDS-ACTION" and instance.free and instance.active:
try:
# First list is BUSY, second BUSY-TENTATIVE, third BUSY-UNAVAILABLE
fbinfo = ([], [], [])
@@ -830,10 +845,11 @@
break
# Now adjust the instance.partstat currently set to "NEEDS-ACTION" to the
- # value determined by auto-accept logic based on instance.free state
+ # value determined by auto-accept logic based on instance.free state. However,
+ # ignore any instance in the past - leave them as NEEDS-ACTION.
partstat_counts = collections.defaultdict(int)
for instance in instances.instances.itervalues():
- if instance.partstat == "NEEDS-ACTION":
+ if instance.partstat == "NEEDS-ACTION" and instance.active:
if automode == "accept-always":
freePartstat = busyPartstat = "ACCEPTED"
elif automode == "decline-always":
@@ -846,14 +862,14 @@
if len(partstat_counts) == 0:
# Nothing to do
- returnValue((False, True, "",))
+ returnValue((False, False, "",))
elif len(partstat_counts) == 1:
# Do the simple case of all PARTSTATs the same separately
# Extract the ATTENDEE property matching current recipient from the calendar data
attendeeProps = calendar.getAttendeeProperties(cuas)
if not attendeeProps:
- returnValue((False, True, "",))
+ returnValue((False, False, "",))
made_changes = False
partstat = partstat_counts.keys()[0]
@@ -862,7 +878,7 @@
store_inbox = partstat == "NEEDS-ACTION"
else:
- # Hard case: some accepted some declined
+ # Hard case: some accepted, some declined, some needs-action
# What we will do is mark any master instance as accepted, then mark each existing
# overridden instance as accepted or declined, and generate new overridden instances for
# any other declines.
@@ -895,7 +911,7 @@
if overridden:
# Change ATTENDEE property to match new state
- if instance.partstat == "NEEDS-ACTION":
+ if instance.partstat == "NEEDS-ACTION" and instance.active:
store_inbox = True
made_changes |= self.resetAttendeePartstat(overridden, cuas, instance.partstat)
else:
@@ -905,7 +921,7 @@
if derived:
attendee = derived.getAttendeeProperty(cuas)
if attendee:
- if instance.partstat == "NEEDS-ACTION":
+ if instance.partstat == "NEEDS-ACTION" and instance.active:
store_inbox = True
self.resetAttendeePartstat(derived, cuas, instance.partstat, hadMasterRsvp)
made_changes = True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130305/52349fcf/attachment-0001.html>
More information about the calendarserver-changes
mailing list