# HG changeset patch # User Paul Boddie # Date 1444776408 -7200 # Node ID e2877c3d0b58ab197abe25f54c0398d672060c88 # Parent 1ee2ae7fdbde8160a2b6b8f2439769b944c9097c Define outgoing users using a combination of sender address and object details. Removed the organiser and attendee check for outgoing handling of ADD messages, adding a new object check. diff -r 1ee2ae7fdbde -r e2877c3d0b58 imiptools/__init__.py --- a/imiptools/__init__.py Tue Oct 13 23:33:25 2015 +0200 +++ b/imiptools/__init__.py Wed Oct 14 00:46:48 2015 +0200 @@ -93,10 +93,15 @@ ).process(msg, senders) # However, outgoing messages do not usually presume anything about the - # eventual recipients and focus on the sender instead. + # eventual recipients and focus on the sender instead. If possible, the + # sender is identified, but since this may be the calendar system (and + # the actual sender is defined in the object), and since the recipient + # may be in a Bcc header that is not available here, it may be left as + # None and deduced from the object content later. else: - Recipient(None, messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug + senders = [sender for sender in get_addresses(get_all_values(msg, "From") or []) if sender != config.MESSAGE_SENDER] + Recipient(senders and senders[0] or None, messenger, store, publisher, preferences_dir, self.handlers, self.outgoing_only, self.debug ).process(msg, senders) def process_args(self, args, stream): diff -r 1ee2ae7fdbde -r e2877c3d0b58 imiptools/handlers/person_outgoing.py --- a/imiptools/handlers/person_outgoing.py Tue Oct 13 23:33:25 2015 +0200 +++ b/imiptools/handlers/person_outgoing.py Wed Oct 14 00:46:48 2015 +0200 @@ -21,7 +21,8 @@ """ from imiptools.client import Client -from imiptools.data import get_uri, uri_dict, uri_values +from imiptools.config import MESSAGE_SENDER +from imiptools.data import get_uri, uri_dict, uri_items, uri_values from imiptools.handlers import Handler from imiptools.handlers.common import CommonEvent @@ -38,9 +39,21 @@ in this way. """ - if self.obj: + if self.obj and not self.user: from_organiser = method in self.organiser_methods - self.user = get_uri(self.obj.get_value(from_organiser and "ORGANIZER" or "ATTENDEE")) + if from_organiser: + self.user = get_uri(self.obj.get_value("ORGANIZER")) + + # Since there may be many attendees in an attendee-provided outgoing + # message, because counter-proposals can have more than one + # attendee, the attendee originating from the calendar system is + # chosen. + + else: + calendar_uri = get_uri(MESSAGE_SENDER) + for attendee, attendee_attr in uri_items(self.obj.get_items("ATTENDEE")): + if attendee_attr.get("SENT-BY") == calendar_uri: + self.user = get_uri(attendee) def _add(self): @@ -49,14 +62,11 @@ if not Client.is_participating(self): return False - # Obtain valid organiser and attendee details. + # Check for event using UID. - oa = self.require_organiser_and_attendees() - if not oa: + if not self.have_new_object(): return False - (organiser, organiser_attr), attendees = oa - # Ignore unknown objects. if not self.get_stored_object_version():