1.1 --- a/actions/SendMessage.py Wed Oct 16 16:11:30 2013 +0200
1.2 +++ b/actions/SendMessage.py Wed Oct 16 16:50:48 2013 +0200
1.3 @@ -12,7 +12,7 @@
1.4 from MoinMoin.Page import Page
1.5 from MoinMoin import config
1.6 from MoinMessage import GPG, MoinMessageError, Message, sendMessage, timestamp
1.7 -from MoinMessageSupport import get_signing_users, get_recipients
1.8 +from MoinMessageSupport import get_signing_users, get_recipients, get_relays
1.9 from MoinSupport import *
1.10 from MoinMoin.wikiutil import escape, MimeType, parseQueryString, \
1.11 taintfilename
1.12 @@ -103,8 +103,6 @@
1.13 "send_selected" : self._get_selected("send", action),
1.14 "queue_label" : escape(_("Queue message for sending")),
1.15 "queue_selected" : self._get_selected("queue", action),
1.16 - "forward_label" : escape(_("Send message for forwarding")),
1.17 - "forward_selected" : self._get_selected("forward", action),
1.18 }
1.19
1.20 # Prepare the output HTML.
1.21 @@ -149,7 +147,6 @@
1.22 <select name="send-action">
1.23 <option value="send" %(send_selected)s>%(send_label)s</option>
1.24 <option value="queue" %(queue_selected)s>%(queue_label)s</option>
1.25 - <option value="forward" %(forward_selected)s>%(forward_label)s</option>
1.26 </select>
1.27 </td>
1.28 </tr>
1.29 @@ -177,7 +174,6 @@
1.30 action = form.get("send-action", ["send"])[0]
1.31
1.32 queue = action == "queue"
1.33 - forward = action == "forward"
1.34
1.35 if not text:
1.36 return 0, _("A message must be given.")
1.37 @@ -293,37 +289,50 @@
1.38 if not parameters.has_key("location"):
1.39 return 0, _("The recipient details are missing a location for sent messages.")
1.40
1.41 - if parameters.get("type") == "url" and not parameters.has_key("fingerprint"):
1.42 + if parameters["type"] in ("url", "relay") and not parameters.has_key("fingerprint"):
1.43 return 0, _("The recipient details are missing a fingerprint for sending messages.")
1.44
1.45 + type = parameters["type"]
1.46 + location = parameters["location"]
1.47 +
1.48 + # Obtain the actual location if a relay is specified.
1.49 +
1.50 + if parameters["type"] == "relay":
1.51 + relays = get_relays(request)
1.52 + if not relays:
1.53 + return 0, _("No relays are defined for MoinMessage, but one is specified for the recipient.")
1.54 + if not relays.has_key(location):
1.55 + return 0, _("The relay specified for the recipient is not defined.")
1.56 +
1.57 + location = relays[location]
1.58 +
1.59 # Sign, encrypt and send the message.
1.60
1.61 message = message.get_payload()
1.62 - type = parameters["type"]
1.63
1.64 - if not queue and type == "url":
1.65 + if not queue and type in ("url", "relay"):
1.66 try:
1.67 if signer:
1.68 message = gpg.signMessage(message, signer)
1.69
1.70 message = gpg.encryptMessage(message, parameters["fingerprint"])
1.71
1.72 - # Add signing for forwarded messages.
1.73 + # Send relayed messages with an extra signature.
1.74
1.75 - relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user")
1.76 + if type == "relay":
1.77 + relaying_user = getattr(self.request.cfg, "moinmessage_gpg_relaying_user")
1.78
1.79 - # Signing with the same identity if no special relaying user is
1.80 - # defined.
1.81 + # Signing with the same identity if no special relaying user is
1.82 + # defined.
1.83
1.84 - if relaying_user:
1.85 - signer = signing_users and signing_users.get(relaying_user)
1.86 + if relaying_user:
1.87 + signer = signing_users and signing_users.get(relaying_user)
1.88
1.89 - if forward and signer:
1.90 timestamp(message)
1.91 message["Update-Action"] = "store"
1.92 message = gpg.signMessage(message, signer)
1.93
1.94 - sendMessage(message, parameters["location"])
1.95 + sendMessage(message, location)
1.96
1.97 except MoinMessageError, exc:
1.98 return 0, "%s: %s" % (_("The message could not be prepared and sent"), exc)
1.99 @@ -331,7 +340,7 @@
1.100 # Or queue the message on the specified page.
1.101
1.102 elif type == "page":
1.103 - page = Page(request, parameters["location"])
1.104 + page = Page(request, location)
1.105 outbox = ItemStore(page, "messages", "message-locks")
1.106 outbox.append(message.as_string())
1.107