1.1 --- a/MoinMessageSupport.py Sun Jul 21 22:40:31 2013 +0200
1.2 +++ b/MoinMessageSupport.py Sun Jul 21 22:41:55 2013 +0200
1.3 @@ -197,4 +197,36 @@
1.4
1.5 return getattr(request.cfg, "moinmessage_gpg_homedir")
1.6
1.7 +def get_signing_users(request):
1.8 +
1.9 + "Return a dictionary mapping usernames to signing keys."
1.10 +
1.11 + return getWikiDict(
1.12 + getattr(request.cfg, "moinmessage_gpg_signing_users_page", "MoinMessageSigningUserDict"),
1.13 + request)
1.14 +
1.15 +def get_recipients(request):
1.16 +
1.17 + """
1.18 + Return the recipients dictionary by first obtaining the page in which it
1.19 + is stored. This page may either be a subpage of the user's home page, if
1.20 + stored on this wiki, or it may be relative to the site root.
1.21 +
1.22 + The name of the subpage is defined by the configuration setting
1.23 + 'moinmessage_gpg_recipients_page', which if absent is set to
1.24 + "MoinMessageRecipientsDict".
1.25 + """
1.26 +
1.27 + subpage = getattr(request.cfg, "moinmessage_gpg_recipients_page", "MoinMessageRecipientsDict")
1.28 + homedetails = wikiutil.getInterwikiHomePage(request)
1.29 +
1.30 + if homedetails:
1.31 + homewiki, homepage = homedetails
1.32 + if homewiki == "Self":
1.33 + recipients = getWikiDict("%s/%s" % (homepage, subpage), request)
1.34 + if recipients:
1.35 + return recipients
1.36 +
1.37 + return getWikiDict(subpage, request)
1.38 +
1.39 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/actions/SendMessage.py Sun Jul 21 22:40:31 2013 +0200
2.2 +++ b/actions/SendMessage.py Sun Jul 21 22:41:55 2013 +0200
2.3 @@ -12,9 +12,10 @@
2.4 from MoinMoin.Page import Page
2.5 from MoinMoin import config
2.6 from MoinMessage import GPG, MoinMessageError, Message, sendMessage, timestamp
2.7 +from MoinMessageSupport import get_signing_users, get_recipients
2.8 from MoinSupport import *
2.9 from MoinMoin.wikiutil import escape, MimeType, parseQueryString, \
2.10 - taintfilename, getInterwikiHomePage
2.11 + taintfilename
2.12
2.13 from email.mime.base import MIMEBase
2.14 from email.mime.image import MIMEImage
2.15 @@ -69,7 +70,7 @@
2.16
2.17 # Get a list of potential recipients.
2.18
2.19 - recipients = self.get_recipients()
2.20 + recipients = get_recipients(request)
2.21
2.22 # Prepare the recipients list, selecting the specified recipients.
2.23
2.24 @@ -271,12 +272,12 @@
2.25 # This is not the same as the details for authenticating users in the
2.26 # PostMessage action since the fingerprints refer to public keys.
2.27
2.28 - signing_users = self.get_signing_users()
2.29 + signing_users = get_signing_users(request)
2.30 signer = signing_users and signing_users.get(request.user.name)
2.31
2.32 # Get the recipient details.
2.33
2.34 - recipients = self.get_recipients()
2.35 + recipients = get_recipients(request)
2.36 if not recipients:
2.37 return 0, _("No recipients page is defined for MoinMessage.")
2.38
2.39 @@ -341,37 +342,6 @@
2.40
2.41 return getattr(self.request.cfg, "moinmessage_gpg_homedir")
2.42
2.43 - def get_recipients(self):
2.44 -
2.45 - """
2.46 - Return the recipients dictionary by first obtaining the page in which it
2.47 - is stored. This page may either be a subpage of the user's home page, if
2.48 - stored on this wiki, or it may be relative to the site root.
2.49 -
2.50 - The name of the subpage is defined by the configuration setting
2.51 - 'moinmessage_gpg_recipients_page', which if absent is set to
2.52 - "MoinMessageRecipientsDict".
2.53 - """
2.54 -
2.55 - request = self.request
2.56 -
2.57 - subpage = getattr(request.cfg, "moinmessage_gpg_recipients_page", "MoinMessageRecipientsDict")
2.58 - homedetails = getInterwikiHomePage(request)
2.59 -
2.60 - if homedetails:
2.61 - homewiki, homepage = homedetails
2.62 - if homewiki == "Self":
2.63 - recipients = getWikiDict("%s/%s" % (homepage, subpage), request)
2.64 - if recipients:
2.65 - return recipients
2.66 -
2.67 - return getWikiDict(subpage, request)
2.68 -
2.69 - def get_signing_users(self):
2.70 - return getWikiDict(
2.71 - getattr(self.request.cfg, "moinmessage_gpg_signing_users_page", "MoinMessageSigningUserDict"),
2.72 - self.request)
2.73 -
2.74 # Special message formatters.
2.75
2.76 def unquoteWikinameURL(url, charset=config.charset):