# HG changeset patch # User Paul Boddie # Date 1381935048 -7200 # Node ID 78827e0d7912b8114b8468712562f2cce15820c2 # Parent c164547084294fc76f861821c8120072060d9ce1 Replaced explicit message forwarding with relay definitions for recipients. diff -r c16454708429 -r 78827e0d7912 MoinMessageSupport.py --- a/MoinMessageSupport.py Wed Oct 16 16:11:30 2013 +0200 +++ b/MoinMessageSupport.py Wed Oct 16 16:50:48 2013 +0200 @@ -214,6 +214,14 @@ getattr(request.cfg, "moinmessage_gpg_signing_users_page", "MoinMessageSigningUserDict"), request) +def get_relays(request): + + "Return a dictionary mapping relays to URLs." + + return getWikiDict( + getattr(request.cfg, "moinmessage_gpg_relays_page", "MoinMessageRelayDict"), + request) + def get_recipients(request): """ diff -r c16454708429 -r 78827e0d7912 README.txt --- a/README.txt Wed Oct 16 16:11:30 2013 +0200 +++ b/README.txt Wed Oct 16 16:50:48 2013 +0200 @@ -96,6 +96,10 @@ their fingerprint-to-user mapping (see moinmessage_gpg_users_page) to be able to receive messages from this wiki. + moinmessage_gpg_relays_page (optional, default is MoinMessageRelayDict) + Where message relaying is specified for a recipient, the relay name will be + looked up in the dictionary provided by this page. + moinmessage_gpg_recipients_page (optional, default is MoinMessageRecipientsDict) This provides a mapping from recipients to remote URLs and key fingerprints. Each user can define the named page as a subpage of their own home page. @@ -219,8 +223,12 @@ Where the type is "url", the accompanying location must be a URL that must itself refer to a resource that can accept MoinMessage content. -Where a type of "url" has been given, a fingerprint must accompany this -information in order to encrypt messages sent to the specified resource. +Where the type is "relay", the accompanying location is an identifier that +must be defined in the relays mapping (see below) and yield a URL that can +accept MoinMessage content. + +Where a type of "url" or "relay" 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. @@ -229,6 +237,18 @@ MoinMessageRecipientsDict unless overridden by the configuration, as a subpage of their own home page. +The Relays Mapping +------------------ + +The mapping from relay identifiers to remote URLs defined by the +MoinMessageRelayDict page is a WikiDict having the following general format: + + relay:: url + +The URL must be able to accept MoinMessage content, and it will typically be +configured so that the user or entity accepting relayed content on the remote +site can store such content for later propagation or retrieval. + Quick Start: Signing, Encrypting and Sending Messages ----------------------------------------------------- diff -r c16454708429 -r 78827e0d7912 actions/SendMessage.py --- a/actions/SendMessage.py Wed Oct 16 16:11:30 2013 +0200 +++ b/actions/SendMessage.py Wed Oct 16 16:50:48 2013 +0200 @@ -12,7 +12,7 @@ from MoinMoin.Page import Page from MoinMoin import config from MoinMessage import GPG, MoinMessageError, Message, sendMessage, timestamp -from MoinMessageSupport import get_signing_users, get_recipients +from MoinMessageSupport import get_signing_users, get_recipients, get_relays from MoinSupport import * from MoinMoin.wikiutil import escape, MimeType, parseQueryString, \ taintfilename @@ -103,8 +103,6 @@ "send_selected" : self._get_selected("send", action), "queue_label" : escape(_("Queue message for sending")), "queue_selected" : self._get_selected("queue", action), - "forward_label" : escape(_("Send message for forwarding")), - "forward_selected" : self._get_selected("forward", action), } # Prepare the output HTML. @@ -149,7 +147,6 @@ @@ -177,7 +174,6 @@ action = form.get("send-action", ["send"])[0] queue = action == "queue" - forward = action == "forward" if not text: return 0, _("A message must be given.") @@ -293,37 +289,50 @@ if not parameters.has_key("location"): return 0, _("The recipient details are missing a location for sent messages.") - if parameters.get("type") == "url" and not parameters.has_key("fingerprint"): + if parameters["type"] in ("url", "relay") and not parameters.has_key("fingerprint"): return 0, _("The recipient details are missing a fingerprint for sending messages.") + type = parameters["type"] + location = parameters["location"] + + # Obtain the actual location if a relay is specified. + + if parameters["type"] == "relay": + relays = get_relays(request) + if not relays: + return 0, _("No relays are defined for MoinMessage, but one is specified for the recipient.") + if not relays.has_key(location): + return 0, _("The relay specified for the recipient is not defined.") + + location = relays[location] + # Sign, encrypt and send the message. message = message.get_payload() - type = parameters["type"] - if not queue and type == "url": + if not queue and type in ("url", "relay"): try: if signer: message = gpg.signMessage(message, signer) message = gpg.encryptMessage(message, parameters["fingerprint"]) - # Add signing for forwarded messages. + # Send relayed messages with an extra signature. - relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user") + if type == "relay": + relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user") - # Signing with the same identity if no special relaying user is - # defined. + # Signing with the same identity if no special relaying user is + # defined. - if relaying_user: - signer = signing_users and signing_users.get(relaying_user) + if relaying_user: + signer = signing_users and signing_users.get(relaying_user) - if forward and signer: timestamp(message) message["Update-Action"] = "store" message = gpg.signMessage(message, signer) - sendMessage(message, parameters["location"]) + sendMessage(message, location) except MoinMessageError, exc: return 0, "%s: %s" % (_("The message could not be prepared and sent"), exc) @@ -331,7 +340,7 @@ # Or queue the message on the specified page. elif type == "page": - page = Page(request, parameters["location"]) + page = Page(request, location) outbox = ItemStore(page, "messages", "message-locks") outbox.append(message.as_string())