# HG changeset patch # User Paul Boddie # Date 1369941150 -7200 # Node ID 4bb9ea7cd0d7cc8555ca7f3ccefa36af3fa91545 # Parent aca93abcb63903992c2ea47431c3c8969ce72975 Changed the recipient configuration and the message sending to support the sending of messages to internal wiki locations. diff -r aca93abcb639 -r 4bb9ea7cd0d7 README.txt --- a/README.txt Sat May 18 01:00:16 2013 +0200 +++ b/README.txt Thu May 30 21:12:30 2013 +0200 @@ -118,12 +118,22 @@ by the MoinMessageRecipientsDict page is a WikiDict having the following general format: - recipient:: URL fingerprint + recipient:: location ... [ fingerprint ] + +Locations are specified as follows: + + type=value + +Where the type is "page", the accompanying value must be a page name. -Each URL must refer to a resource that can accept MoinMessage content. +Where the type is "url", the accompanying value must be a URL that must itself +refer to a resource that can accept MoinMessage content. -Each fingerprint corresponds to a key used by the remote site (as identified -by the URL) for the decryption of messages. +Where a location of type "url" has been given, a fingerprint must accompany +this information in order to encrypt messages sent to the specified resource. + +Each fingerprint corresponds to a key used by the Wiki to encrypt messages and +by the remote site (as identified by the URL) to decrypt messages. Quick Start: Signing, Encrypting and Sending Messages ----------------------------------------------------- diff -r aca93abcb639 -r 4bb9ea7cd0d7 actions/SendMessage.py --- a/actions/SendMessage.py Sat May 18 01:00:16 2013 +0200 +++ b/actions/SendMessage.py Thu May 30 21:12:30 2013 +0200 @@ -9,6 +9,7 @@ from MoinMoin.action import ActionBase, AttachFile from MoinMoin.formatter import text_html from MoinMoin.log import getLogger +from MoinMoin.Page import Page from MoinMoin import config from MoinMessage import GPG, MoinMessageError, Message, sendMessage from MoinSupport import * @@ -207,27 +208,37 @@ if not recipient_details: return 0, _("The specified recipient is not present in the list of known contacts.") - try: - url, fingerprint = recipient_details.split() - except ValueError: - return 0, _("The recipient details were not in the correct format: url, fingerprint.") + parameters = parseDictEntry(recipient_details, ("fingerprint",)) + + if not parameters.has_key("page") and not parameters.has_key("url"): + return 0, _("The recipient details are missing a location for sent messages.") + + if parameters.has_key("url") and not parameters.has_key("fingerprint"): + return 0, _("The recipient details are missing a fingerprint for sending messages.") # Sign, encrypt and send the message. message = message.get_payload() - if not queue: + if not queue and parameters.has_key("url"): try: if signer: message = gpg.signMessage(message, signer) - message = gpg.encryptMessage(message, fingerprint) - sendMessage(message, url) + message = gpg.encryptMessage(message, parameters["fingerprint"]) + sendMessage(message, parameters["url"]) except MoinMessageError, exc: return 0, "%s: %s" % (_("The message could not be prepared and sent:"), exc) - # Or queue the message. + # Or queue the message on the specified page. + + elif parameters.has_key("page"): + page = Page(request, parameters["page"]) + outbox = ItemStore(page, "messages", "message-locks") + outbox.append(message.as_string()) + + # Or queue the message in a special outbox. else: outbox = ItemStore(request.page, "outgoing-messages", "outgoing-message-locks")