[CalendarServer-changes] [13469] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 13 13:55:17 PDT 2014
Revision: 13469
http://trac.calendarserver.org//changeset/13469
Author: sagen at apple.com
Date: 2014-05-13 13:55:17 -0700 (Tue, 13 May 2014)
Log Message:
-----------
Decorate ATTENDEE properties with a parameter indicating their hosted status (e.g. local or external). Currently off by default.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/stdconfig.py
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-05-09 23:38:16 UTC (rev 13468)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py 2014-05-13 20:55:17 UTC (rev 13469)
@@ -639,6 +639,19 @@
"RemoveDuplicatePrivateComments": False, # Remove duplicate private comments on PUT
+ "HostedStatus": {
+ "Enabled": False, # Decorate ATTENDEEs with the following parameter
+ # to indicate where the ATTENDEE is hosted, locally
+ # or externally. It's configurable and extensible in
+ # case we want to add more values. A value of empty
+ # string means no decoration.
+ "Parameter": "X-APPLE-HOSTED-STATUS",
+ "Values": {
+ "local": "",
+ "external": "EXTERNAL",
+ },
+ },
+
"RevisionCleanup": {
"Enabled": True,
"SyncTokenLifetimeDays" : 14.0, # Number of days that a client sync report token is valid
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-05-09 23:38:16 UTC (rev 13468)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2014-05-13 20:55:17 UTC (rev 13469)
@@ -2428,6 +2428,33 @@
@inlineCallbacks
+ def decorateHostedStatus(self, component):
+ """
+ Scan the component for attendees; if any are hosted externally (e.g.
+ they don't exist in our directory) add the attribute:
+ X-APPLE-HOSTED-STATUS=EXTERNAL
+ """
+ dir = self.directoryService()
+ for sub in component.subcomponents():
+ for attendee in sub.getAllAttendeeProperties():
+ value = attendee.value()
+
+ record = yield dir.recordWithCalendarUserAddress(value)
+ if record is None:
+ status = "external"
+ else:
+ status = "local"
+
+ if config.HostedStatus.Values[status]:
+ attendee.setParameter(
+ config.HostedStatus.Parameter,
+ config.HostedStatus.Values[status]
+ )
+ else:
+ attendee.removeParameter(config.HostedStatus.Parameter)
+
+
+ @inlineCallbacks
def doImplicitScheduling(self, component, inserting, internal_state, split_details=None):
new_component = None
@@ -2673,6 +2700,10 @@
# Process structured location
yield self.addStructuredLocation(component)
+ # Process hosted status
+ if config.HostedStatus.Enabled:
+ yield self.decorateHostedStatus(component)
+
# Do scheduling
implicit_result = (yield self.doImplicitScheduling(component, inserting, internal_state))
if isinstance(implicit_result, int):
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2014-05-09 23:38:16 UTC (rev 13468)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2014-05-13 20:55:17 UTC (rev 13469)
@@ -70,6 +70,7 @@
import datetime
+
class CalendarSQLStorageTests(CalendarCommonTests, unittest.TestCase):
"""
Calendar SQL storage tests.
@@ -2223,7 +2224,58 @@
yield self.commit()
+ @inlineCallbacks
+ def test_setComponent_externalPrincipal(self):
+ """
+ Verify attendees who are not locally hosted have X-APPLE-HOSTED-STATUS=EXTERNAL
+ attribute added.
+ """
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//Mac OS X 10.9.1//EN
+BEGIN:VEVENT
+UID:561F5DBB-3F38-4B3A-986F-DD05CBAF554F
+DTSTART;TZID=America/Los_Angeles:20131211T164500
+DTEND;TZID=America/Los_Angeles:20131211T174500
+ATTENDEE;X-APPLE-HOSTED-STATUS=EXTERNAL:urn:x-uid:user01
+ATTENDEE:mailto:someone_external at example.com
+CREATED:20131211T221854Z
+DTSTAMP:20131211T230632Z
+ORGANIZER:urn:x-uid:user01
+SUMMARY:external
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ self.patch(config.HostedStatus, "Enabled", True)
+
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield calendar.createCalendarObjectWithName("external.ics",
+ Component.fromString(data))
+ cobj = yield self.calendarObjectUnderTest(name="external.ics",
+ calendar_name="calendar", home="user01")
+ comp = yield cobj.component()
+ components = list(comp.subcomponents())
+
+ # Check attendees...
+
+ # The local user will have the X-APPLE-HOSTED-STATUS param removed...
+ local = components[0].getAttendeeProperty(["urn:x-uid:user01"])
+ self.assertFalse(local.hasParameter(config.HostedStatus.Parameter))
+
+ # The external one will have it added...
+ external = components[0].getAttendeeProperty(["mailto:someone_external at example.com"])
+ self.assertEquals(
+ external.parameterValue(config.HostedStatus.Parameter),
+ config.HostedStatus.Values["external"]
+ )
+
+ yield self.commit()
+
+
+
class CalendarObjectSplitting(CommonCommonTests, unittest.TestCase):
"""
CalendarObject splitting tests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140513/cbf7d9d2/attachment.html>
More information about the calendarserver-changes
mailing list