1.1 --- a/imiptools/handlers/person.py Tue Nov 25 21:59:42 2014 +0100
1.2 +++ b/imiptools/handlers/person.py Tue Nov 25 22:08:44 2014 +0100
1.3 @@ -6,7 +6,7 @@
1.4
1.5 from email.mime.text import MIMEText
1.6 from imiptools.config import MANAGER_PATH, MANAGER_URL
1.7 -from imiptools.content import Handler, to_part
1.8 +from imiptools.content import Handler, get_uri, to_part
1.9 from imiptools.handlers.common import CommonFreebusy
1.10 from socket import gethostname
1.11 from vCalendar import to_node
1.12 @@ -32,9 +32,12 @@
1.13 if not self.validate_identities(from_organiser and [organiser_item] or attendees.items()):
1.14 return False
1.15
1.16 - # Process each attendee separately.
1.17 + # Handle notifications and invitations.
1.18
1.19 if from_organiser:
1.20 +
1.21 + # Process each attendee separately.
1.22 +
1.23 for attendee, attendee_attr in attendees.items():
1.24
1.25 if not self.have_new_object(attendee, objtype):
1.26 @@ -73,6 +76,25 @@
1.27
1.28 return True
1.29
1.30 + def _record_freebusy(self, from_organiser=True):
1.31 +
1.32 + "Record free/busy information for the received information."
1.33 +
1.34 + freebusy = []
1.35 + for value in self.get_values("FREEBUSY"):
1.36 + if not isinstance(value, list):
1.37 + value = [value]
1.38 + for v in value:
1.39 + try:
1.40 + start, end = v.split("/", 1)
1.41 + freebusy.append((start, end))
1.42 + except ValueError:
1.43 + pass
1.44 +
1.45 + for sender, sender_attr in self.get_items(from_organiser and "ORGANIZER" or "ATTENDEE"):
1.46 + for recipient in self.recipients:
1.47 + self.store.set_freebusy_for_other(get_uri(recipient), freebusy, sender)
1.48 +
1.49 def reply(self):
1.50
1.51 "Wrap any valid message and pass it on to the recipient."
1.52 @@ -157,7 +179,9 @@
1.53
1.54 def publish(self):
1.55
1.56 - # NOTE: Register free/busy information.
1.57 + "Register free/busy information."
1.58 +
1.59 + self._record_freebusy(from_organiser=True)
1.60
1.61 # The message is now wrapped and passed on to the recipient.
1.62
1.63 @@ -167,7 +191,7 @@
1.64
1.65 "Record replies and notify the recipient."
1.66
1.67 - self._record_and_deliver("VFREEBUSY", from_organiser=False, queue=False)
1.68 + self._record_freebusy(from_organiser=False)
1.69 return PersonHandler.reply(self)
1.70
1.71 def request(self):