summaryrefslogtreecommitdiff
path: root/wallace/module_resources.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-17 23:01:51 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-07-17 23:01:51 (GMT)
commit2c9f4f4af7fbfe7739a32794eda5c0045cc85280 (patch)
tree7d3c1708836afafe387e86b50fe4969cc6dd14ef /wallace/module_resources.py
parent31a96c533281c2e25b5b324bc49361b13b77853c (diff)
parent21b33ad600d70e178eb48a9053314f58559fccfa (diff)
downloadpykolab-2c9f4f4af7fbfe7739a32794eda5c0045cc85280.tar.gz
Merge branch 'master' of ssh://git.kolabsys.com/git/pykolab
Diffstat (limited to 'wallace/module_resources.py')
-rw-r--r--wallace/module_resources.py44
1 files changed, 39 insertions, 5 deletions
diff --git a/wallace/module_resources.py b/wallace/module_resources.py
index 525cc3b..a4873f4 100644
--- a/wallace/module_resources.py
+++ b/wallace/module_resources.py
@@ -274,7 +274,6 @@ def execute(*args, **kw):
_ee = to_dt(event.get_end())
_ie = to_dt(itip['end'].dt)
-
if _es < _is:
if _es <= _ie:
if _ee <= _is:
@@ -386,7 +385,7 @@ def execute(*args, **kw):
itip_event['xml'].to_message().as_string()
)
- send_response(resources[resource]['mail'], itip_events)
+ send_response(resources[resource]['mail'], itip_event)
else:
# This must have been a resource collection originally.
@@ -395,15 +394,29 @@ def execute(*args, **kw):
if resources[resource].has_key('memberof'):
original_resource = resources[resources[resource]['memberof']]
+ # Randomly selects a target resource from the resource
+ # collection.
_target_resource = resources[original_resource['uniquemember'][random.randint(0,(len(original_resource['uniquemember'])-1))]]
- # unset all
+ # Remove all resources from the collection.
for _r in original_resource['uniquemember']:
del resources[_r]
if original_resource['mail'] in [a.get_email() for a in itip_event['xml'].get_attendees()]:
+ #
+ # Delegate:
+ #
+ # - delegator: the original resource collection
+ # - delegatee: the target resource
+ #
+
+ itip_event['xml'].delegate(
+ original_resource['mail'],
+ _target_resource['mail']
+ )
+
itip_event['xml'].set_attendee_participant_status(
- [a for a in itip_event['xml'].get_attendees() if a.get_email() == original_resource['mail']][0],
+ [a for a in itip_event['xml'].get_attendees() if a.get_email() == _target_resource['mail']][0],
"ACCEPTED"
)
@@ -414,6 +427,8 @@ def execute(*args, **kw):
level=9
)
+ # TODO: The Cyrus IMAP (or Dovecot) Administrator login
+ # name comes from configuration.
imap.imap.m.setacl(_target_resource['kolabtargetfolder'], "cyrus-admin", "lrswipkxtecda")
imap.imap.m.append(
_target_resource['kolabtargetfolder'],
@@ -422,7 +437,7 @@ def execute(*args, **kw):
itip_event['xml'].to_message().as_string()
)
- send_response(original_resource['mail'], itip_events)
+ send_response(original_resource['mail'], itip_event)
# Disconnect IMAP or we lock the mailbox almost constantly
imap.disconnect()
@@ -478,6 +493,8 @@ def itip_events_from_message(message):
for c in cal.walk():
if c.name == "VEVENT":
+ itip = {}
+
# From the event, take the following properties:
#
# - start
@@ -717,9 +734,26 @@ def send_response(from_address, itip_events):
if conf.debuglevel > 8:
smtp.set_debuglevel(True)
+ if isinstance(itip_events, dict):
+ itip_events = [ itip_events ]
+
for itip_event in itip_events:
attendee = [a for a in itip_event['xml'].get_attendees() if a.get_email() == from_address][0]
participant_status = itip_event['xml'].get_ical_attendee_participant_status(attendee)
+
+ if participant_status == "DELEGATED":
+ # Extra actions to take
+ delegator = [a for a in itip_event['xml'].get_attendees() if a.get_email() == from_address][0]
+ delegatee = [a for a in itip_event['xml'].get_attendees() if from_address in [b.email() for b in a.get_delegated_from()]][0]
+
+ itip_event['xml'].event.setAttendees([ delegator, delegatee ])
+
+ message = itip_event['xml'].to_message_itip(delegatee.get_email(), method="REPLY", participant_status=itip_event['xml'].get_ical_attendee_participant_status(delegatee))
+ smtp.sendmail(message['From'], message['To'], message.as_string())
+
+ itip_event['xml'].event.setAttendees([a for a in itip_event['xml'].get_attendees() if a.get_email() == from_address])
+
message = itip_event['xml'].to_message_itip(from_address, method="REPLY", participant_status=participant_status)
smtp.sendmail(message['From'], message['To'], message.as_string())
+
smtp.quit()