<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13684] CalendarServer/branches/users/gaya/groupsharee2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13684">13684</a></dd>
<dt>Author</dt> <dd>gaya@apple.com</dd>
<dt>Date</dt> <dd>2014-06-25 02:28:53 -0700 (Wed, 25 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>more schema changes. Most logic. (Missing group sharee access control).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2project">CalendarServer/branches/users/gaya/groupsharee2/.project</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2twistedcaldavstdconfigpy">CalendarServer/branches/users/gaya/groupsharee2/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresqlpy">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemacurrentoracledialectsql">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current-oracle-dialect.sql</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemacurrentsql">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current.sql</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaoldoracledialectv43sql">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_43_to_44sql">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_43_to_44sql">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_43_to_44.sql</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_tablespy">CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_tables.py</a></li>
<li><a href="#CalendarServerbranchesusersgayagroupsharee2txdavwhogroupspy">CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesusersgayagroupsharee2project"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/.project (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/.project        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/.project        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -3,19 +3,10 @@
</span><span class="cx">         <name>CalendarServer</name>
</span><span class="cx">         <comment></comment>
</span><span class="cx">         <projects>
</span><del>-                <project>CalDAVClientLibrary</project>
-                <project>cffi</project>
-                <project>psutil</project>
-                <project>pyasn1</project>
</del><ins>+                <project>caldavclientlibrary</project>
+                <project>kerberos</project>
</ins><span class="cx">                 <project>pycalendar</project>
</span><del>-                <project>pycparser</project>
-                <project>pycrypto</project>
-                <project>PyGreSQL</project>
-                <project>python-ldap-2.3.13</project>
-                <project>sqlparse</project>
</del><span class="cx">                 <project>twextpy</project>
</span><del>-                <project>Twisted</project>
-                <project>zope.interface-4.0.3</project>
</del><span class="cx">         </projects>
</span><span class="cx">         <buildSpec>
</span><span class="cx">                 <buildCommand>
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2twistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/twistedcaldav/stdconfig.py (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/twistedcaldav/stdconfig.py        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/twistedcaldav/stdconfig.py        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -598,7 +598,7 @@
</span><span class="cx"> "MaxBytesBatchUpload" : 10485760, # Maximum size of a batch POST (10 MB)
</span><span class="cx">
</span><span class="cx"> "Sharing": {
</span><del>- "Enabled" : False, # Overall on/off switch
</del><ins>+ "Enabled" : True, # Overall on/off switch
</ins><span class="cx"> "AllowExternalUsers" : False, # External (non-principal) sharees allowed
</span><span class="cx">
</span><span class="cx"> "Calendars" : {
</span><span class="lines">@@ -619,6 +619,10 @@
</span><span class="cx"> "Global": [
</span><span class="cx"> ],
</span><span class="cx"> },
</span><ins>+ "Groups" : {
+ "Enabled" : False, # Calendar Group sharing on/off switch
+ "ReconciliationDelaySeconds" : 5,
+ },
</ins><span class="cx"> },
</span><span class="cx"> "AddressBooks" : {
</span><span class="cx"> "Enabled" : False, # Address Book sharing on/off switch
</span><span class="lines">@@ -632,7 +636,7 @@
</span><span class="cx"> ],
</span><span class="cx"> },
</span><span class="cx"> "Groups" : {
</span><del>- "Enabled" : False, # Address Book Group sharing on/off switch
</del><ins>+ "Enabled" : False, # Address Book Group sharing on/off switch
</ins><span class="cx"> },
</span><span class="cx"> },
</span><span class="cx"> },
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcaldavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/caldav/datastore/sql.py        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> from twext.python.clsprop import classproperty
</span><span class="cx"> from twext.python.filepath import CachingFilePath
</span><span class="cx"> from twext.python.log import Logger
</span><ins>+from twext.who.idirectory import RecordType
</ins><span class="cx"> from twistedcaldav.ical import Component as VComponent
</span><span class="cx"> from txweb2.http_headers import MimeType, generateContentType
</span><span class="cx"> from txweb2.stream import readStream
</span><span class="lines">@@ -87,7 +88,8 @@
</span><span class="cx"> CommonObjectResource, ECALENDARTYPE
</span><span class="cx"> from txdav.common.datastore.sql_tables import _ATTACHMENTS_MODE_NONE, \
</span><span class="cx"> _ATTACHMENTS_MODE_WRITE, schema, _BIND_MODE_OWN, \
</span><del>- _ATTACHMENTS_MODE_READ, _TRANSP_OPAQUE, _TRANSP_TRANSPARENT
</del><ins>+ _ATTACHMENTS_MODE_READ, _TRANSP_OPAQUE, _TRANSP_TRANSPARENT, \
+ _BIND_MODE_GROUP
</ins><span class="cx"> from txdav.common.icommondatastore import IndexedSearchException, \
</span><span class="cx"> InternalDataStoreError, HomeChildNameAlreadyExistsError, \
</span><span class="cx"> HomeChildNameNotAllowedError, ObjectResourceTooBigError, \
</span><span class="lines">@@ -95,7 +97,7 @@
</span><span class="cx"> ObjectResourceNameNotAllowedError, TooManyObjectResourcesError, \
</span><span class="cx"> InvalidUIDError, UIDExistsError, UIDExistsElsewhereError, \
</span><span class="cx"> InvalidResourceMove, InvalidComponentForStoreError, \
</span><del>- NoSuchObjectResourceError, ConcurrentModification
</del><ins>+ NoSuchObjectResourceError, ConcurrentModification, AllRetriesFailed
</ins><span class="cx"> from txdav.xml import element
</span><span class="cx"> from txdav.xml.parser import WebDAVDocument
</span><span class="cx">
</span><span class="lines">@@ -1753,6 +1755,147 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><ins>+ #===============================================================================
+ # Group sharing
+ #===============================================================================
+ @inlineCallbacks
+ def shareWithUID(self, shareeUID, mode, status=None, summary=None, shareName=None):
+ """
+ Share this (owned) L{CommonHomeChild} with another principal.
+
+ @param shareeUID: The UID of the sharee.
+ @type: L{str}
+
+ @param mode: The sharing mode; L{_BIND_MODE_READ} or
+ L{_BIND_MODE_WRITE} or L{_BIND_MODE_DIRECT}
+ @type mode: L{str}
+
+ @param status: The sharing status; L{_BIND_STATUS_INVITED} or
+ L{_BIND_STATUS_ACCEPTED}
+ @type: L{str}
+
+ @param summary: The proposed message to go along with the share, which
+ will be used as the default display name.
+ @type: L{str}
+
+ @return: the name of the shared calendar in the new calendar home.
+ @rtype: L{str}
+ """
+ record = (
+ yield self._txn.directoryService().recordWithUID(shareeUID.decode("utf-8"))
+ ) if True or (
+ config.Sharing.Enabled and
+ config.Sharing.Calendars.Enabled and
+ config.Sharing.Calendars.Groups.Enabled
+ ) else None
+
+ if record is None or record.recordType != RecordType.group:
+ shareeHome = yield self._txn.calendarHomeWithUID(shareeUID, create=True)
+ returnValue(
+ (yield self.shareWith(shareeHome, mode, status, summary, shareName))
+ )
+
+ # shareWith every member of group not already shared to
+ members = yield record.expandedMembers()
+ for member in members:
+ shareeHome = yield self._txn.calendarHomeWithUID(member.uid(), create=True)
+ if (yield shareeHome.childWithID(self._resourceID)) is None:
+ yield self.shareWith(shareeHome, _BIND_MODE_GROUP, status)
+
+ yield self.updateGroupLink(shareeUID, mode)
+ returnValue(None)
+
+
+ @inlineCallbacks
+ def reconcileGroupSharee(self, groupUID):
+ """
+ reconcile bind table with group members
+ """
+ changed = False
+ if (yield self.updateShareeGroupLink, groupUID):
+ record = (
+ yield self._txn.directoryService().recordWithUID(groupUID.decode("utf-8"))
+ ) if True or (
+ config.Sharing.Enabled and
+ config.Sharing.Calendars.Enabled and
+ config.Sharing.Calendars.Groups.Enabled
+ ) else None
+ members = yield record.expandedMembers() if record is not None else []
+ memberUIDs = set([member.uid() for member in members])
+ boundUIDs = set()
+
+ bind = schema.CALENDAR_BIND
+ rows = yield Select(
+ [bind.HOME_RESOURCE_ID],
+ From=bind,
+ Where=bind.CALENDAR_RESOURCE_ID == self._resourceID.And(
+ bind.BIND_MODE == _BIND_MODE_GROUP
+ ),
+ ).on(self._txn)
+ groupShareeHomeIDs = [row[0] for row in rows]
+ for groupShareeHomeID in groupShareeHomeIDs:
+ shareeHome = yield self._txn.calendarHomeWithResourceID(groupShareeHomeID, create=True)
+ if shareeHome.uid() in memberUIDs:
+ boundUIDs.add(shareeHome.uid())
+ else:
+ shareeView = yield shareeHome.childWithID(self._resourceID)
+ yield self.removeShare(shareeView)
+ changed = True
+
+ for member in [member for member in members if member.uid() not in boundUIDs]:
+ shareeHome = yield self._txn.calendarHomeWithUID(member.uid(), create=True)
+ if (yield shareeHome.childWithID(self._resourceID)) is None:
+ yield self.shareWith(shareeHome, _BIND_MODE_GROUP)
+ changed = True
+
+ returnValue(changed)
+
+
+ @inlineCallbacks
+ def updateShareeGroupLink(self, groupUID, mode=None):
+ """
+ update schema.GROUP_SHAREE
+ """
+ changed = False
+ groupID, _ignore_name, membershipHash, _ignore_modDate = yield self._txn.groupByUID(groupUID)
+
+ gs = schema.GROUP_SHAREE
+ rows = yield Select(
+ [gs.MEMBERSHIP_HASH, gs.MODE],
+ From=gs,
+ Where=gs.HOME_ID == self.ownerHome()._resourceID.And(
+ gs.CALENDAR_ID == self._resourceID).And(
+ gs.GROUP_ID == groupID)
+ ).on(self._txn)
+ if rows:
+ [[gsMembershipHash, gsMode]] = rows
+ updateMap = {}
+ if gsMembershipHash != membershipHash:
+ updateMap[gs.MEMBERSHIP_HASH] = membershipHash
+ if mode is not None and gsMode != mode:
+ updateMap[gs.GROUP_BIND_MODE] = mode
+ if updateMap:
+ yield Update(
+ updateMap,
+ Where=gs.HOME_ID == self.ownerHome()._resourceID.And(
+ gs.CALENDAR_ID == self._resourceID).And(
+ gs.GROUP_ID == groupID
+ )
+ ).on(self._txn)
+ changed = True
+ else:
+ yield Insert({
+ gs.MEMBERSHIP_HASH: membershipHash,
+ gs.GROUP_BIND_MODE: mode,
+ gs.HOME_ID: self.ownerHome()._resourceID,
+ gs.CALENDAR_ID: self._resourceID,
+ gs.GROUP_ID: groupID,
+ }).on(self._txn)
+ changed = True
+
+ returnValue(changed)
+
+
</ins><span class="cx"> icalfbtype_to_indexfbtype = {
</span><span class="cx"> "UNKNOWN" : 0,
</span><span class="cx"> "FREE" : 1,
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql.py        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -4703,7 +4703,35 @@
</span><span class="cx"> returnValue(shareeView)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @inlineCallbacks
+ def shareWithUID(self, shareeUID, mode, status=None, summary=None, shareName=None):
+ """
+ Share this (owned) L{CommonHomeChild} with another principal.
</ins><span class="cx">
</span><ins>+ @param shareeUID: The UID of the sharee.
+ @type: L{str}
+
+ @param mode: The sharing mode; L{_BIND_MODE_READ} or
+ L{_BIND_MODE_WRITE} or L{_BIND_MODE_DIRECT}
+ @type mode: L{str}
+
+ @param status: The sharing status; L{_BIND_STATUS_INVITED} or
+ L{_BIND_STATUS_ACCEPTED}
+ @type: L{str}
+
+ @param summary: The proposed message to go along with the share, which
+ will be used as the default display name.
+ @type: L{str}
+
+ @return: the name of the shared calendar in the new calendar home.
+ @rtype: L{str}
+ """
+ shareeHome = yield self._txn.calendarHomeWithUID(shareeUID, create=True)
+ returnValue(
+ (yield self.shareWith(shareeHome, mode, status, summary, shareName))
+ )
+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def shareWith(self, shareeHome, mode, status=None, summary=None, shareName=None):
</span><span class="cx"> """
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemacurrentoracledialectsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current-oracle-dialect.sql (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current-oracle-dialect.sql        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -401,13 +401,6 @@
</span><span class="cx"> "GROUP_UID" nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create table GROUP_ATTENDEE_RECONCILE_WORK (
- "WORK_ID" integer primary key not null,
- "JOB_ID" integer not null references JOB,
- "RESOURCE_ID" integer,
- "GROUP_ID" integer
-);
-
</del><span class="cx"> create table GROUPS (
</span><span class="cx"> "GROUP_ID" integer primary key,
</span><span class="cx"> "NAME" nvarchar2(255),
</span><span class="lines">@@ -424,6 +417,13 @@
</span><span class="cx"> primary key ("GROUP_ID", "MEMBER_UID")
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+create table GROUP_ATTENDEE_RECONCILE_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "RESOURCE_ID" integer,
+ "GROUP_ID" integer
+);
+
</ins><span class="cx"> create table GROUP_ATTENDEE (
</span><span class="cx"> "GROUP_ID" integer not null references GROUPS on delete cascade,
</span><span class="cx"> "RESOURCE_ID" integer not null references CALENDAR_OBJECT on delete cascade,
</span><span class="lines">@@ -431,13 +431,20 @@
</span><span class="cx"> primary key ("GROUP_ID", "RESOURCE_ID")
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+create table GROUP_SHAREE_RECONCILE_WORK (
+ "WORK_ID" integer primary key not null,
+ "JOB_ID" integer not null references JOB,
+ "CALENDAR_ID" integer not null references CALENDAR on delete cascade,
+ "GROUP_ID" integer not null references GROUPS on delete cascade
+);
+
</ins><span class="cx"> create table GROUP_SHAREE (
</span><span class="cx"> "GROUP_ID" integer not null references GROUPS on delete cascade,
</span><del>- "CALENDAR_HOME_RESOURCE_ID" integer not null references CALENDAR_HOME on delete cascade,
- "CALENDAR_RESOURCE_ID" integer not null references CALENDAR on delete cascade,
</del><ins>+ "CALENDAR_HOME_ID" integer not null references CALENDAR_HOME on delete cascade,
+ "CALENDAR_ID" integer not null references CALENDAR on delete cascade,
</ins><span class="cx"> "GROUP_BIND_MODE" integer not null,
</span><span class="cx"> "MEMBERSHIP_HASH" nvarchar2(255),
</span><del>- primary key ("GROUP_ID", "CALENDAR_HOME_RESOURCE_ID", "CALENDAR_RESOURCE_ID")
</del><ins>+ primary key ("GROUP_ID", "CALENDAR_HOME_ID", "CALENDAR_ID")
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> create table DELEGATES (
</span><span class="lines">@@ -579,7 +586,7 @@
</span><span class="cx"> "VALUE" nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '43');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '44');
</ins><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</span><span class="lines">@@ -737,10 +744,6 @@
</span><span class="cx"> JOB_ID
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
- JOB_ID
-);
-
</del><span class="cx"> create index GROUPS_GROUP_UID_b35cce23 on GROUPS (
</span><span class="cx"> GROUP_UID
</span><span class="cx"> );
</span><span class="lines">@@ -749,14 +752,22 @@
</span><span class="cx"> MEMBER_UID
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_ATTENDEE_RESOUR_855124dc on GROUP_ATTENDEE (
</del><ins>+create index GROUP_ATTENDEE_RECONC_da73d3c2 on GROUP_ATTENDEE_RECONCILE_WORK (
+ JOB_ID
+);
+
+create index GROUP_ATTENDEE_ID_d497ffdb on GROUP_ATTENDEE (
</ins><span class="cx"> RESOURCE_ID
</span><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_SHAREE_RESOURCE_cc288b3b on CALENDAR_BIND (
- CALENDAR_RESOURCE_ID
</del><ins>+create index GROUP_SHAREE_RECONCIL_9aad0858 on GROUP_SHAREE_RECONCILE_WORK (
+ JOB_ID
</ins><span class="cx"> );
</span><span class="cx">
</span><ins>+create index GROUP_SHAREE_CALENDAR_28a88850 on GROUP_SHAREE (
+ CALENDAR_ID
+);
+
</ins><span class="cx"> create index DELEGATE_TO_DELEGATOR_5e149b11 on DELEGATES (
</span><span class="cx"> DELEGATE,
</span><span class="cx"> READ_WRITE,
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemacurrentsql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current.sql (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current.sql        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/current.sql        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -213,7 +213,7 @@
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (2, 'write');
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (3, 'direct');
</span><span class="cx"> insert into CALENDAR_BIND_MODE values (4, 'indirect');
</span><del>-insert into CALENDAR_BIND_MODE values (5, 'group');                        -- bind mode is determined by group bind mode. TODO: May not be needed
</del><ins>+insert into CALENDAR_BIND_MODE values (5, 'group');
</ins><span class="cx">
</span><span class="cx"> -- Enumeration of statuses
</span><span class="cx">
</span><span class="lines">@@ -767,17 +767,6 @@
</span><span class="cx"> create index GROUP_REFRESH_WORK_JOB_ID on
</span><span class="cx"> GROUP_REFRESH_WORK(JOB_ID);
</span><span class="cx">
</span><del>-create table GROUP_ATTENDEE_RECONCILE_WORK (
- WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
- JOB_ID integer references JOB not null,
- RESOURCE_ID integer,
- GROUP_ID integer
-);
-
-create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
- GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
-
-
</del><span class="cx"> create table GROUPS (
</span><span class="cx"> GROUP_ID integer primary key default nextval('RESOURCE_ID_SEQ'), -- implicit index
</span><span class="cx"> NAME varchar(255) not null,
</span><span class="lines">@@ -800,6 +789,17 @@
</span><span class="cx"> create index GROUP_MEMBERSHIP_MEMBER on
</span><span class="cx"> GROUP_MEMBERSHIP(MEMBER_UID);
</span><span class="cx">
</span><ins>+create table GROUP_ATTENDEE_RECONCILE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer not null references JOB,
+ RESOURCE_ID integer,        -- FIXME add: not null references CALENDAR_OBJECT on delete cascade,
+ GROUP_ID integer                -- FIXME add: not null references GROUPS on delete cascade
+);
+
+create index GROUP_ATTENDEE_RECONCILE_WORK_JOB_ID on
+ GROUP_ATTENDEE_RECONCILE_WORK(JOB_ID);
+
+
</ins><span class="cx"> create table GROUP_ATTENDEE (
</span><span class="cx"> GROUP_ID integer not null references GROUPS on delete cascade,
</span><span class="cx"> RESOURCE_ID integer not null references CALENDAR_OBJECT on delete cascade,
</span><span class="lines">@@ -807,22 +807,34 @@
</span><span class="cx">
</span><span class="cx"> primary key (GROUP_ID, RESOURCE_ID)
</span><span class="cx"> );
</span><del>-create index GROUP_ATTENDEE_RESOURCE_ID on
</del><ins>+
+create index GROUP_ATTENDEE_ID on
</ins><span class="cx"> GROUP_ATTENDEE(RESOURCE_ID);
</span><span class="cx">
</span><ins>+
+ create table GROUP_SHAREE_RECONCILE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer not null references JOB,
+ CALENDAR_ID integer        not null references CALENDAR on delete cascade,
+ GROUP_ID integer not null references GROUPS on delete cascade
+);
</ins><span class="cx">
</span><ins>+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on
+ GROUP_SHAREE_RECONCILE_WORK(JOB_ID);
+
+
</ins><span class="cx"> create table GROUP_SHAREE (
</span><span class="cx"> GROUP_ID integer not null references GROUPS on delete cascade,
</span><del>- CALENDAR_HOME_RESOURCE_ID         integer not null references CALENDAR_HOME on delete cascade,
- CALENDAR_RESOURCE_ID         integer not null references CALENDAR on delete cascade,
</del><ins>+ CALENDAR_HOME_ID                                 integer not null references CALENDAR_HOME on delete cascade,
+ CALENDAR_ID                                 integer not null references CALENDAR on delete cascade,
</ins><span class="cx"> GROUP_BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
</span><span class="cx"> MEMBERSHIP_HASH varchar(255) not null,
</span><span class="cx">
</span><del>- primary key (GROUP_ID, CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID) -- implicit index
</del><ins>+ primary key (GROUP_ID, CALENDAR_HOME_ID, CALENDAR_ID)
</ins><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_SHAREE_RESOURCE_ID on
- CALENDAR_BIND(CALENDAR_RESOURCE_ID);
</del><ins>+create index GROUP_SHAREE_CALENDAR_ID on
+ GROUP_SHAREE(CALENDAR_ID);
</ins><span class="cx">
</span><span class="cx"> ---------------
</span><span class="cx"> -- Delegates --
</span><span class="lines">@@ -1098,7 +1110,7 @@
</span><span class="cx"> VALUE varchar(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-insert into CALENDARSERVER values ('VERSION', '43');
</del><ins>+insert into CALENDARSERVER values ('VERSION', '44');
</ins><span class="cx"> insert into CALENDARSERVER values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaoldoracledialectv43sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/old/oracle-dialect/v43.sql        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx"> "VALUE" nvarchar2(255)
</span><span class="cx"> );
</span><span class="cx">
</span><del>-insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '44');
</del><ins>+insert into CALENDARSERVER (NAME, VALUE) values ('VERSION', '43');
</ins><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('CALENDAR-DATAVERSION', '6');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('ADDRESSBOOK-DATAVERSION', '2');
</span><span class="cx"> insert into CALENDARSERVER (NAME, VALUE) values ('NOTIFICATION-DATAVERSION', '1');
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradesoracledialectupgrade_from_43_to_44sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_43_to_44.sql        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -18,20 +18,33 @@
</span><span class="cx"> -- Upgrade database schema from VERSION 43 to 44 --
</span><span class="cx"> ---------------------------------------------------
</span><span class="cx">
</span><del>-insert into CALENDAR_BIND_MODE values (5, 'group');                        -- bind mode is determined by group bind mode. TODO: May not be needed
</del><ins>+insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values ('group', 5);
</ins><span class="cx">
</span><ins>+create table GROUP_SHAREE_RECONCILE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer not null references JOB,
+ CALENDAR_ID integer        not null references CALENDAR on delete cascade,
+ GROUP_ID integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on GROUP_SHAREE_RECONCILE_WORK(
+        JOB_ID
+);
+
+
</ins><span class="cx"> create table GROUP_SHAREE (
</span><span class="cx"> GROUP_ID integer not null references GROUPS on delete cascade,
</span><del>- CALENDAR_HOME_RESOURCE_ID         integer not null references CALENDAR_HOME on delete cascade,
- CALENDAR_RESOURCE_ID         integer not null references CALENDAR on delete cascade,
</del><ins>+ CALENDAR_HOME_ID                                 integer not null references CALENDAR_HOME on delete cascade,
+ CALENDAR_ID                                 integer not null references CALENDAR on delete cascade,
</ins><span class="cx"> GROUP_BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
</span><span class="cx"> MEMBERSHIP_HASH varchar(255) not null,
</span><span class="cx">
</span><del>- primary key (GROUP_ID, CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID) -- implicit index
</del><ins>+ primary key (GROUP_ID, CALENDAR_HOME_ID, CALENDAR_ID) -- implicit index
</ins><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_SHAREE_RESOURCE_ID on
- CALENDAR_BIND(CALENDAR_RESOURCE_ID);
</del><ins>+create index GROUP_SHAREE_CALENDAR_ID on GROUP_SHAREE(
+        CALENDAR_ID
+);
</ins><span class="cx">
</span><span class="cx"> -- update the version
</span><span class="cx"> update CALENDARSERVER set VALUE = '44' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_schemaupgradespostgresdialectupgrade_from_43_to_44sql"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_43_to_44.sql (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_43_to_44.sql        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_schema/upgrades/postgres-dialect/upgrade_from_43_to_44.sql        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -18,20 +18,31 @@
</span><span class="cx"> -- Upgrade database schema from VERSION 43 to 44 --
</span><span class="cx"> ---------------------------------------------------
</span><span class="cx">
</span><del>-insert into CALENDAR_BIND_MODE (DESCRIPTION, ID) values (5, 'group');                        -- bind mode is determined by group bind mode. TODO: May not be needed
</del><ins>+insert into CALENDAR_BIND_MODE values (5, 'group');
</ins><span class="cx">
</span><ins>+create table GROUP_SHAREE_RECONCILE_WORK (
+ WORK_ID integer primary key default nextval('WORKITEM_SEQ') not null, -- implicit index
+ JOB_ID integer not null references JOB,
+ CALENDAR_ID integer        not null references CALENDAR on delete cascade,
+ GROUP_ID integer not null references GROUPS on delete cascade
+);
+
+create index GROUP_SHAREE_RECONCILE_WORK_JOB_ID on
+ GROUP_SHAREE_RECONCILE_WORK(JOB_ID);
+
+
</ins><span class="cx"> create table GROUP_SHAREE (
</span><span class="cx"> GROUP_ID integer not null references GROUPS on delete cascade,
</span><del>- CALENDAR_HOME_RESOURCE_ID         integer not null references CALENDAR_HOME on delete cascade,
- CALENDAR_RESOURCE_ID         integer not null references CALENDAR on delete cascade,
</del><ins>+ CALENDAR_HOME_ID                                 integer not null references CALENDAR_HOME on delete cascade,
+ CALENDAR_ID                                 integer not null references CALENDAR on delete cascade,
</ins><span class="cx"> GROUP_BIND_MODE integer not null, -- enum CALENDAR_BIND_MODE
</span><span class="cx"> MEMBERSHIP_HASH varchar(255) not null,
</span><span class="cx">
</span><del>- primary key (GROUP_ID, CALENDAR_HOME_RESOURCE_ID, CALENDAR_RESOURCE_ID) -- implicit index
</del><ins>+ primary key (GROUP_ID, CALENDAR_HOME_ID, CALENDAR_ID) -- implicit index
</ins><span class="cx"> );
</span><span class="cx">
</span><del>-create index GROUP_SHAREE_RESOURCE_ID on
- CALENDAR_BIND(CALENDAR_RESOURCE_ID);
</del><ins>+create index GROUP_SHAREE_CALENDAR_ID on
+ GROUP_SHAREE(CALENDAR_ID);
</ins><span class="cx">
</span><del>- -- update the version
</del><ins>+-- update the version
</ins><span class="cx"> update CALENDARSERVER set VALUE = '44' where NAME = 'VERSION';
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavcommondatastoresql_tablespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_tables.py (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_tables.py        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/common/datastore/sql_tables.py        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -230,6 +230,7 @@
</span><span class="cx"> _BIND_MODE_WRITE = _bindMode('write')
</span><span class="cx"> _BIND_MODE_DIRECT = _bindMode('direct')
</span><span class="cx"> _BIND_MODE_INDIRECT = _bindMode('indirect')
</span><ins>+_BIND_MODE_GROUP = _bindMode('group')
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> _addressBookObjectKind = _schemaConstants(
</span></span></pre></div>
<a id="CalendarServerbranchesusersgayagroupsharee2txdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py (13683 => 13684)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py        2014-06-25 02:26:01 UTC (rev 13683)
+++ CalendarServer/branches/users/gaya/groupsharee2/txdav/who/groups.py        2014-06-25 09:28:53 UTC (rev 13684)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
</span><span class="cx"> from txdav.caldav.datastore.sql import CalendarStoreFeatures, ComponentUpdateState
</span><del>-from txdav.common.datastore.sql_tables import schema
</del><ins>+from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
</ins><span class="cx"> import datetime
</span><span class="cx"> import hashlib
</span><span class="cx">
</span><span class="lines">@@ -218,6 +218,41 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><ins>+class GroupShareeReconciliationWork(
+ WorkItem, fromTable(schema.GROUP_SHAREE_RECONCILE_WORK)
+):
+
+ group = property(
+ lambda self: (self.table.CALENDAR_ID == self.calendarID)
+ )
+
+
+ @inlineCallbacks
+ def doWork(self):
+
+ # Delete all other work items for this event
+ yield Delete(
+ From=self.table,
+ Where=self.group,
+ ).on(self.transaction)
+
+ bind = schema.CALENDAR_BIND
+ rows = yield Select(
+ [bind.HOME_RESOURCE_ID],
+ From=bind,
+ Where=bind.CALENDAR_RESOURCE_ID == self.calendarID.And(
+ bind.BIND_MODE == _BIND_MODE_OWN
+ ),
+ ).on(self.transaction)
+ if rows:
+ homeID = rows[0][0]
+ home = yield self.transaction.calendarHomeWithResourceID(homeID)
+ calendar = yield home.childWithID(self.calendarID)
+
+ yield calendar.reconcileGroupSharee(self.groupUID)
+
+
+
</ins><span class="cx"> def diffAssignments(old, new):
</span><span class="cx"> """
</span><span class="cx"> Compare two proxy assignment lists and return their differences in the form
</span><span class="lines">@@ -310,11 +345,11 @@
</span><span class="cx"> ) in changed:
</span><span class="cx"> readDelegateGroupID = writeDelegateGroupID = None
</span><span class="cx"> if readDelegateUID:
</span><del>- readDelegateGroupID, _ignore_name, hash, _ignore_modified = (
</del><ins>+ readDelegateGroupID, _ignore_name, _ignore_hash, _ignore_modified = (
</ins><span class="cx"> yield txn.groupByUID(readDelegateUID)
</span><span class="cx"> )
</span><span class="cx"> if writeDelegateUID:
</span><del>- writeDelegateGroupID, _ignore_name, hash, _ignore_modified = (
</del><ins>+ writeDelegateGroupID, _ignore_name, _ignore_hash, _ignore_modified = (
</ins><span class="cx"> yield txn.groupByUID(writeDelegateUID)
</span><span class="cx"> )
</span><span class="cx"> yield txn.assignExternalDelegates(
</span><span class="lines">@@ -384,7 +419,8 @@
</span><span class="cx"> newMemberUIDs.add(member.uid)
</span><span class="cx"> yield self.synchronizeMembers(txn, groupID, newMemberUIDs)
</span><span class="cx">
</span><del>- wps = yield self.scheduleEventReconciliations(txn, groupID)
</del><ins>+ wps = yield self.scheduleGroupAttendeeReconciliations(txn, groupID)
+ wps = wps + (yield self.scheduleGroupShareeReconciliations(txn, groupID))
</ins><span class="cx">
</span><span class="cx"> returnValue(wps)
</span><span class="cx">
</span><span class="lines">@@ -429,7 +465,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def scheduleEventReconciliations(self, txn, groupID):
</del><ins>+ def scheduleGroupAttendeeReconciliations(self, txn, groupID):
</ins><span class="cx"> """
</span><span class="cx"> Find all events who have this groupID as an attendee and create
</span><span class="cx"> work items for them.
</span><span class="lines">@@ -455,22 +491,48 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><ins>+ def scheduleGroupShareeReconciliations(self, txn, groupID):
+ """
+ Find all calendars who have shared to this groupID and create
+ work items for them.
+ returns: WorkProposal
+ """
+ gs = schema.GROUP_SHAREE
+ rows = yield Select(
+ [gs.CALENDAR_ID, ],
+ From=gs,
+ Where=gs.GROUP_ID == groupID,
+ ).on(txn)
+
+ wps = []
+ for [calendarID] in rows:
+ wp = yield GroupShareeReconciliationWork.reschedule(
+ txn,
+ seconds=float(config.Sharing.Calendar.Groups.ReconciliationDelaySeconds),
+ calendarID=calendarID,
+ groupID=groupID,
+ )
+ wps.append(wp)
+ returnValue(tuple(wps))
+
+
+ @inlineCallbacks
</ins><span class="cx"> def groupsToRefresh(self, txn):
</span><span class="cx"> delegatedUIDs = set((yield txn.allGroupDelegates()))
</span><span class="cx"> self.log.info(
</span><span class="cx"> "There are {count} group delegates", count=len(delegatedUIDs)
</span><span class="cx"> )
</span><span class="cx">
</span><del>- # Get groupUIDs for aoo group attendees
- groupAttendee = schema.GROUP_ATTENDEE
</del><ins>+ # Get groupUIDs for all group attendees
+ ga = schema.GROUP_ATTENDEE
</ins><span class="cx"> gr = schema.GROUPS
</span><span class="cx"> rows = yield Select(
</span><span class="cx"> [gr.GROUP_UID],
</span><span class="cx"> From=gr,
</span><span class="cx"> Where=gr.GROUP_ID.In(
</span><span class="cx"> Select(
</span><del>- [groupAttendee.GROUP_ID],
- From=groupAttendee,
</del><ins>+ [ga.GROUP_ID],
+ From=ga,
</ins><span class="cx"> Distinct=True
</span><span class="cx"> )
</span><span class="cx"> )
</span><span class="lines">@@ -480,6 +542,25 @@
</span><span class="cx"> "There are {count} group attendees", count=len(attendeeGroupUIDs)
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ # Get groupUIDs for all group shares
+ gs = schema.GROUP_SHAREE
+ gr = schema.GROUPS
+ rows = yield Select(
+ [gr.GROUP_UID],
+ From=gr,
+ Where=gr.GROUP_ID.In(
+ Select(
+ [gs.GROUP_ID],
+ From=gs,
+ Distinct=True
+ )
+ )
+ ).on(txn)
+ shareeGroupUIDs = set([row[0] for row in rows])
+ self.log.info(
+ "There are {count} group sharees", count=len(shareeGroupUIDs)
+ )
+
</ins><span class="cx"> # FIXME: is this a good place to clear out unreferenced groups?
</span><span class="cx">
</span><del>- returnValue(delegatedUIDs.union(attendeeGroupUIDs))
</del><ins>+ returnValue((delegatedUIDs | attendeeGroupUIDs | shareeGroupUIDs))
</ins></span></pre>
</div>
</div>
</body>
</html>