diff --git a/daemon.py b/daemon.py
index a9936d22e..a6d2e837b 100644
--- a/daemon.py
+++ b/daemon.py
@@ -25,6 +25,10 @@ from webfinger import webfingerLookup
from webfinger import webfingerHandle
from metadata import metaDataNodeInfo
from metadata import metaDataInstance
+from pgp import getEmailAddress
+from pgp import setEmailAddress
+from pgp import getPGPpubKey
+from pgp import setPGPpubKey
from xmpp import getXmppAddress
from xmpp import setXmppAddress
from matrix import getMatrixAddress
@@ -1170,6 +1174,7 @@ class PubServer(BaseHTTPRequestHandler):
if len(optionsList)>3:
optionsLink=optionsList[3]
donateUrl=None
+ PGPpubKey=None
xmppAddress=None
matrixAddress=None
actorJson=getPersonFromCache(self.server.baseDir,optionsActor,self.server.personCache)
@@ -1177,6 +1182,8 @@ class PubServer(BaseHTTPRequestHandler):
donateUrl=getDonationUrl(actorJson)
xmppAddress=getXmppAddress(actorJson)
matrixAddress=getMatrixAddress(actorJson)
+ emailAddress=getEmailAddress(actorJson)
+ PGPpubKey=getPGPpubKey(actorJson)
msg=htmlPersonOptions(self.server.translate, \
self.server.baseDir, \
self.server.domain, \
@@ -1185,7 +1192,8 @@ class PubServer(BaseHTTPRequestHandler):
optionsProfileUrl, \
optionsLink, \
pageNumber,donateUrl, \
- xmppAddress,matrixAddress).encode()
+ xmppAddress,matrixAddress, \
+ PGPpubKey,emailAddress).encode()
self._set_headers('text/html',len(msg),cookie)
self._write(msg)
return
@@ -4279,6 +4287,11 @@ class PubServer(BaseHTTPRequestHandler):
if fields.get('themeDropdown'):
setTheme(self.server.baseDir,fields['themeDropdown'])
#self.server.iconsCache={}
+ if fields.get('email'):
+ currentEmailAddress=getEmailAddress(actorJson)
+ if fields['emailAddress']!=currentEmailAddress:
+ setEmailAddress(actorJson,fields['email'])
+ actorChanged=True
if fields.get('xmppAddress'):
currentXmppAddress=getXmppAddress(actorJson)
if fields['xmppAddress']!=currentXmppAddress:
@@ -4289,6 +4302,11 @@ class PubServer(BaseHTTPRequestHandler):
if fields['matrixAddress']!=currentMatrixAddress:
setMatrixAddress(actorJson,fields['matrixAddress'])
actorChanged=True
+ if fields.get('pgp'):
+ currentPGPpubKey=getPGPpubKey(actorJson)
+ if fields['pgp']!=currentPGPpubKey:
+ setPGPpubKey(actorJson,fields['pgp'])
+ actorChanged=True
if fields.get('donateUrl'):
currentDonateUrl=getDonationUrl(actorJson)
if fields['donateUrl']!=currentDonateUrl:
diff --git a/pgp.py b/pgp.py
new file mode 100644
index 000000000..00cd5cad7
--- /dev/null
+++ b/pgp.py
@@ -0,0 +1,113 @@
+__filename__ = "pgp.py"
+__author__ = "Bob Mottram"
+__license__ = "AGPL3+"
+__version__ = "1.1.0"
+__maintainer__ = "Bob Mottram"
+__email__ = "bob@freedombone.net"
+__status__ = "Production"
+
+import json
+
+def getEmailAddress(actorJson: {}) -> str:
+ """Returns the email address for the given actor
+ """
+ if not actorJson.get('attachment'):
+ return ''
+ for propertyValue in actorJson['attachment']:
+ if not propertyValue.get('name'):
+ continue
+ if not propertyValue['name'].lower().startswith('email'):
+ continue
+ if not propertyValue.get('type'):
+ continue
+ if not propertyValue.get('value'):
+ continue
+ if propertyValue['type']!='PropertyValue':
+ continue
+ if '@' not in propertyValue['value']:
+ continue
+ if '.' not in propertyValue['value']:
+ continue
+ return propertyValue['value']
+ return ''
+
+def getPGPpubKey(actorJson: {}) -> str:
+ """Returns PGP public key for the given actor
+ """
+ if not actorJson.get('attachment'):
+ return ''
+ for propertyValue in actorJson['attachment']:
+ if not propertyValue.get('name'):
+ continue
+ if not propertyValue['name'].lower().startswith('pgp'):
+ continue
+ if not propertyValue.get('type'):
+ continue
+ if not propertyValue.get('value'):
+ continue
+ if propertyValue['type']!='PropertyValue':
+ continue
+ if '-BEGIN PUBLIC KEY-' not in propertyValue['value']:
+ continue
+ return propertyValue['value']
+ return ''
+
+def setEmailAddress(actorJson: {},emailAddress: str) -> None:
+ """Sets the email address for the given actor
+ """
+ if not actorJson.get('attachment'):
+ actorJson['attachment']=[]
+
+ if '@' not in emailAddress:
+ return
+ if '.' not in emailAddress:
+ return
+ if emailAddress.startswith('@'):
+ return
+
+ for propertyValue in actorJson['attachment']:
+ if not propertyValue.get('name'):
+ continue
+ if not propertyValue.get('type'):
+ continue
+ if not propertyValue['name'].lower().startswith('email'):
+ continue
+ if propertyValue['type']!='PropertyValue':
+ continue
+ propertyValue['value']=emailAddress
+ return
+
+ newEmailAddress={
+ "name": "Email",
+ "type": "PropertyValue",
+ "value": emailAddress
+ }
+ actorJson['attachment'].append(newEmailAddress)
+
+def setPGPpubKey(actorJson: {},PGPpubKey: str) -> None:
+ """Sets a PGP public key for the given actor
+ """
+ if not actorJson.get('attachment'):
+ actorJson['attachment']=[]
+
+ if '-BEGIN PUBLIC KEY-' not in PGPpubKey:
+ return
+
+ for propertyValue in actorJson['attachment']:
+ if not propertyValue.get('name'):
+ continue
+ if not propertyValue.get('type'):
+ continue
+ if not propertyValue['name'].lower().startswith('pgp'):
+ continue
+ if propertyValue['type']!='PropertyValue':
+ continue
+ propertyValue['value']=PGPpubKey
+ return
+
+ newPGPpubKey={
+ "name": "PGP",
+ "type": "PropertyValue",
+ "value": PGPpubKey
+ }
+ actorJson['attachment'].append(newPGPpubKey)
diff --git a/webinterface.py b/webinterface.py
index e6eb5d154..7868860ee 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -18,6 +18,8 @@ from shutil import copyfileobj
from pprint import pprint
from person import personBoxJson
from person import isPersonSnoozed
+from pgp import getEmailAddress
+from pgp import getPGPpubKey
from xmpp import getXmppAddress
from matrix import getMatrixAddress
from donate import getDonationUrl
@@ -588,6 +590,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
displayNickname=nickname
bioStr=''
donateUrl=''
+ emailAddress=''
+ PGPpubKey=''
xmppAddress=''
matrixAddress=''
manuallyApprovesFollowers=''
@@ -596,6 +600,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
donateUrl=getDonationUrl(actorJson)
xmppAddress=getXmppAddress(actorJson)
matrixAddress=getMatrixAddress(actorJson)
+ emailAddress=getEmailAddress(actorJson)
+ PGPpubKey=getPGPpubKey(actorJson)
if actorJson.get('name'):
displayNickname=actorJson['name']
if actorJson.get('summary'):
@@ -721,6 +727,10 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
editProfileForm+=' '
editProfileForm+='
'
editProfileForm+=' '
+ editProfileForm+='
'
+ editProfileForm+=' '
+ editProfileForm+='
'
+ editProfileForm+=' '
editProfileForm+=' '
editProfileForm+='
Email: '+emailAddress+'
\n' if xmppAddress: donateSection+='XMPP: '+xmppAddress+'
\n' if matrixAddress: donateSection+='Matrix: '+matrixAddress+'
\n' + if PGPpubKey: + donateSection+='PGP: '+PGPpubKey+'
\n' donateSection+='Email: '+emailAddress+'
' if xmppAddress: optionsStr+='XMPP: '+xmppAddress+'
' if matrixAddress: optionsStr+='Matrix: '+matrixAddress+'
' + if PGPpubKey: + optionsStr+='PGP: '+PGPpubKey+'
' optionsStr+='