# HG changeset patch # User Paul Boddie # Date 1418937533 -3600 # Node ID cba0ca85b83eb14f2303bbad390b7abe88d3c797 # Parent d915725f25c0405eeebbafbb249b6694a70ed260 Tidied up the messages accompanying calendar objects. diff -r d915725f25c0 -r cba0ca85b83e imiptools/handlers/person.py --- a/imiptools/handlers/person.py Thu Dec 18 19:21:28 2014 +0100 +++ b/imiptools/handlers/person.py Thu Dec 18 22:18:53 2014 +0100 @@ -15,6 +15,9 @@ url_base = MANAGER_URL or "http://%s/" % gethostname() return "%s/%s" % (url_base.rstrip("/"), MANAGER_PATH.lstrip("/")) +def get_object_url(uid): + return "%s/%s" % (get_manager_url().rstrip("/"), uid) + class PersonHandler(Handler): "Handling mechanisms specific to people." @@ -99,13 +102,18 @@ for recipient in self.recipients: self.store.set_freebusy_for_other(get_uri(recipient), freebusy, sender) - def reply(self): + def wrap(self, method, text, from_organiser=True, link=True): "Wrap any valid message and pass it on to the recipient." - attendee = get_address(self.get_value("ATTENDEE")) - if attendee: - return "REPLY", MIMEText("A reply has been received from %s." % attendee) + texts = [] + texts.append(text) + if link: + texts.append("If your mail program cannot handle this " + "message, you may view the details here:\n\n%s" % + get_object_url(self.uid)) + + return method, MIMEText("\n".join(texts)) class Event(PersonHandler): @@ -145,26 +153,24 @@ def publish(self): - # NOTE: Register details of any relevant event. + "Register details of any relevant event." - # The message is now wrapped and passed on to the recipient. - - return "PUBLISH", MIMEText("Details of an event have been received.") + self._record_and_deliver("VEVENT", from_organiser=True, queue=False) + return self.wrap("PUBLISH", "Details of an event have been received.", from_organiser=True, link=True) def refresh(self): - # NOTE: Update details of any active event. + "Update details of any active event." - # The message is now wrapped and passed on to the recipient. - - return "REFRESH", MIMEText("An event update has been received.") + self._record_and_deliver("VEVENT", from_organiser=True, queue=False) + return self.wrap("REFRESH", "An event update has been received.", from_organiser=True, link=True) def reply(self): "Record replies and notify the recipient." self._record_and_deliver("VEVENT", from_organiser=False, queue=False) - return PersonHandler.reply(self) + return self.wrap("REPLY", "A reply has been received.", from_organiser=False, link=True) def request(self): @@ -174,8 +180,7 @@ # The message is now wrapped and passed on to the recipient. - url = "%s/%s" % (get_manager_url().rstrip("/"), self.uid) - return "REQUEST", MIMEText("A request has been queued and can be viewed here: %s" % url) + return "REQUEST", MIMEText("A request has been queued and can be viewed here: %s" % get_object_url(self.uid)) class Freebusy(PersonHandler, CommonFreebusy): @@ -185,18 +190,19 @@ "Register free/busy information." - self._record_freebusy(from_organiser=True) + # NOTE: This could be configured to not produce a message. - # The message is now wrapped and passed on to the recipient. - - return "PUBLISH", MIMEText("Details of a contact's availability have been received.") + self._record_freebusy(from_organiser=True) + return self.wrap("PUBLISH", "A free/busy update has been received.", from_organiser=True, link=False) def reply(self): "Record replies and notify the recipient." + # NOTE: This could be configured to not produce a message. + self._record_freebusy(from_organiser=False) - return PersonHandler.reply(self) + return self.wrap("REPLY", "A reply has been received.", from_organiser=False, link=False) def request(self): @@ -235,7 +241,8 @@ # The message is now wrapped and passed on to the recipient. - return "PUBLISH", MIMEText("Details of a journal entry have been received.") + self._record_and_deliver("VJOURNAL", from_organiser=True, queue=False) + return self.wrap("PUBLISH", "Details of a journal entry have been received.", from_organiser=True, link=False) class Todo(PersonHandler): @@ -275,26 +282,24 @@ def publish(self): - # NOTE: Register details of any relevant item. + "Register details of any relevant item." - # The message is now wrapped and passed on to the recipient. - - return "PUBLISH", MIMEText("Details of an item have been received.") + self._record_and_deliver("VTODO", from_organiser=True, queue=False) + return self.wrap("PUBLISH", "Details of an item have been received.", from_organiser=True, link=True) def refresh(self): - # NOTE: Update details of any active item. + "Update details of any active item." - # The message is now wrapped and passed on to the recipient. - - return "REFRESH", MIMEText("An item update has been received.") + self._record_and_deliver("VTODO", from_organiser=True, queue=False) + return self.wrap("REFRESH", "An item update has been received.", from_organiser=True, link=True) def reply(self): "Record replies and notify the recipient." self._record_and_deliver("VTODO", from_organiser=False, queue=False) - return PersonHandler.reply(self) + return self.wrap("REPLY", "A reply has been received.", from_organiser=False, link=True) def request(self): diff -r d915725f25c0 -r cba0ca85b83e imiptools/mail.py --- a/imiptools/mail.py Thu Dec 18 19:21:28 2014 +0100 +++ b/imiptools/mail.py Thu Dec 18 22:18:53 2014 +0100 @@ -9,7 +9,7 @@ MESSAGE_SUBJECT = "Calendar system message" MESSAGE_TEXT = """\ -This is a response to a calendar message sent by your calendar program. +This is a message from the calendar system. """ PREAMBLE_TEXT = """\