1.1 --- a/imip_resource.py Wed Oct 22 00:48:30 2014 +0200
1.2 +++ b/imip_resource.py Wed Oct 22 14:06:26 2014 +0200
1.3 @@ -5,7 +5,7 @@
1.4 """
1.5
1.6 from datetime import date, datetime, timedelta
1.7 -from imiptools.content import Handler, format_datetime, get_value, parse_object
1.8 +from imiptools.content import Handler, format_datetime
1.9 from imiptools.period import insert_period, period_overlaps, remove_period
1.10 from vCalendar import to_node
1.11 from vRecurrence import get_parameters, get_rule
1.12 @@ -70,26 +70,8 @@
1.13
1.14 # Check for event using UID.
1.15
1.16 - f = self.store.get_event(attendee, self.uid)
1.17 - event = f and parse_object(f, "utf-8", "VEVENT")
1.18 -
1.19 - # If found, compare SEQUENCE and potentially DTSTAMP.
1.20 -
1.21 - if event:
1.22 - sequence = get_value(event, "SEQUENCE")
1.23 - dtstamp = get_value(event, "DTSTAMP")
1.24 -
1.25 - # If the request refers to an older version of the event, ignore
1.26 - # it.
1.27 -
1.28 - old_dtstamp = self.dtstamp < dtstamp
1.29 -
1.30 - if sequence is not None and (
1.31 - int(self.sequence) < int(sequence) or
1.32 - int(self.sequence) == int(sequence) and old_dtstamp
1.33 - ) or old_dtstamp:
1.34 -
1.35 - continue
1.36 + if not self.have_new_object(attendee, "VEVENT"):
1.37 + continue
1.38
1.39 # If newer than any old version, discard old details from the
1.40 # free/busy record and check for suitability.
2.1 --- a/imiptools/__init__.py Wed Oct 22 00:48:30 2014 +0200
2.2 +++ b/imiptools/__init__.py Wed Oct 22 14:06:26 2014 +0200
2.3 @@ -71,8 +71,6 @@
2.4 if part.get_content_type() in itip_content_types and \
2.5 part.get_param("method"):
2.6
2.7 - # NOTE: Act on behalf of resources for now.
2.8 -
2.9 all_parts += handle_itip_part(part, original_recipients, self.handlers)
2.10
2.11 # Pack the parts into a single message.
3.1 --- a/imiptools/content.py Wed Oct 22 00:48:30 2014 +0200
3.2 +++ b/imiptools/content.py Wed Oct 22 14:06:26 2014 +0200
3.3 @@ -274,6 +274,12 @@
3.4 return self.recipients.intersection(map(get_address, values))
3.5
3.6 def require_organiser_and_attendees(self):
3.7 +
3.8 + """
3.9 + Return the organiser and attendees for the current object, filtered by
3.10 + the recipients of interest. Return None if no identities are eligible.
3.11 + """
3.12 +
3.13 attendee_map = self.get_value_map("ATTENDEE")
3.14 organiser = self.get_item("ORGANIZER")
3.15
3.16 @@ -288,6 +294,36 @@
3.17
3.18 return organiser, attendees
3.19
3.20 + def have_new_object(self, attendee, objtype):
3.21 +
3.22 + """
3.23 + Return whether the current object is new to the 'attendee' for the
3.24 + given 'objtype'.
3.25 + """
3.26 +
3.27 + f = self.store.get_event(attendee, self.uid)
3.28 + event = f and parse_object(f, "utf-8", objtype)
3.29 +
3.30 + # If found, compare SEQUENCE and potentially DTSTAMP.
3.31 +
3.32 + if event:
3.33 + sequence = get_value(event, "SEQUENCE")
3.34 + dtstamp = get_value(event, "DTSTAMP")
3.35 +
3.36 + # If the request refers to an older version of the event, ignore
3.37 + # it.
3.38 +
3.39 + old_dtstamp = self.dtstamp < dtstamp
3.40 +
3.41 + if sequence is not None and (
3.42 + int(self.sequence) < int(sequence) or
3.43 + int(self.sequence) == int(sequence) and old_dtstamp
3.44 + ) or old_dtstamp:
3.45 +
3.46 + return False
3.47 +
3.48 + return True
3.49 +
3.50 # Handler registry.
3.51
3.52 methods = {