forked from indymedia/epicyon
Add email address and pgp public key to profile
parent
ac7893d388
commit
c06a80bae0
20
daemon.py
20
daemon.py
|
@ -25,6 +25,10 @@ from webfinger import webfingerLookup
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from metadata import metaDataNodeInfo
|
from metadata import metaDataNodeInfo
|
||||||
from metadata import metaDataInstance
|
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 getXmppAddress
|
||||||
from xmpp import setXmppAddress
|
from xmpp import setXmppAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
|
@ -1170,6 +1174,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if len(optionsList)>3:
|
if len(optionsList)>3:
|
||||||
optionsLink=optionsList[3]
|
optionsLink=optionsList[3]
|
||||||
donateUrl=None
|
donateUrl=None
|
||||||
|
PGPpubKey=None
|
||||||
xmppAddress=None
|
xmppAddress=None
|
||||||
matrixAddress=None
|
matrixAddress=None
|
||||||
actorJson=getPersonFromCache(self.server.baseDir,optionsActor,self.server.personCache)
|
actorJson=getPersonFromCache(self.server.baseDir,optionsActor,self.server.personCache)
|
||||||
|
@ -1177,6 +1182,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
donateUrl=getDonationUrl(actorJson)
|
donateUrl=getDonationUrl(actorJson)
|
||||||
xmppAddress=getXmppAddress(actorJson)
|
xmppAddress=getXmppAddress(actorJson)
|
||||||
matrixAddress=getMatrixAddress(actorJson)
|
matrixAddress=getMatrixAddress(actorJson)
|
||||||
|
emailAddress=getEmailAddress(actorJson)
|
||||||
|
PGPpubKey=getPGPpubKey(actorJson)
|
||||||
msg=htmlPersonOptions(self.server.translate, \
|
msg=htmlPersonOptions(self.server.translate, \
|
||||||
self.server.baseDir, \
|
self.server.baseDir, \
|
||||||
self.server.domain, \
|
self.server.domain, \
|
||||||
|
@ -1185,7 +1192,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
optionsProfileUrl, \
|
optionsProfileUrl, \
|
||||||
optionsLink, \
|
optionsLink, \
|
||||||
pageNumber,donateUrl, \
|
pageNumber,donateUrl, \
|
||||||
xmppAddress,matrixAddress).encode()
|
xmppAddress,matrixAddress, \
|
||||||
|
PGPpubKey,emailAddress).encode()
|
||||||
self._set_headers('text/html',len(msg),cookie)
|
self._set_headers('text/html',len(msg),cookie)
|
||||||
self._write(msg)
|
self._write(msg)
|
||||||
return
|
return
|
||||||
|
@ -4279,6 +4287,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('themeDropdown'):
|
if fields.get('themeDropdown'):
|
||||||
setTheme(self.server.baseDir,fields['themeDropdown'])
|
setTheme(self.server.baseDir,fields['themeDropdown'])
|
||||||
#self.server.iconsCache={}
|
#self.server.iconsCache={}
|
||||||
|
if fields.get('email'):
|
||||||
|
currentEmailAddress=getEmailAddress(actorJson)
|
||||||
|
if fields['emailAddress']!=currentEmailAddress:
|
||||||
|
setEmailAddress(actorJson,fields['email'])
|
||||||
|
actorChanged=True
|
||||||
if fields.get('xmppAddress'):
|
if fields.get('xmppAddress'):
|
||||||
currentXmppAddress=getXmppAddress(actorJson)
|
currentXmppAddress=getXmppAddress(actorJson)
|
||||||
if fields['xmppAddress']!=currentXmppAddress:
|
if fields['xmppAddress']!=currentXmppAddress:
|
||||||
|
@ -4289,6 +4302,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields['matrixAddress']!=currentMatrixAddress:
|
if fields['matrixAddress']!=currentMatrixAddress:
|
||||||
setMatrixAddress(actorJson,fields['matrixAddress'])
|
setMatrixAddress(actorJson,fields['matrixAddress'])
|
||||||
actorChanged=True
|
actorChanged=True
|
||||||
|
if fields.get('pgp'):
|
||||||
|
currentPGPpubKey=getPGPpubKey(actorJson)
|
||||||
|
if fields['pgp']!=currentPGPpubKey:
|
||||||
|
setPGPpubKey(actorJson,fields['pgp'])
|
||||||
|
actorChanged=True
|
||||||
if fields.get('donateUrl'):
|
if fields.get('donateUrl'):
|
||||||
currentDonateUrl=getDonationUrl(actorJson)
|
currentDonateUrl=getDonationUrl(actorJson)
|
||||||
if fields['donateUrl']!=currentDonateUrl:
|
if fields['donateUrl']!=currentDonateUrl:
|
||||||
|
|
|
@ -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)
|
|
@ -18,6 +18,8 @@ from shutil import copyfileobj
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from person import personBoxJson
|
from person import personBoxJson
|
||||||
from person import isPersonSnoozed
|
from person import isPersonSnoozed
|
||||||
|
from pgp import getEmailAddress
|
||||||
|
from pgp import getPGPpubKey
|
||||||
from xmpp import getXmppAddress
|
from xmpp import getXmppAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
|
@ -588,6 +590,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
||||||
displayNickname=nickname
|
displayNickname=nickname
|
||||||
bioStr=''
|
bioStr=''
|
||||||
donateUrl=''
|
donateUrl=''
|
||||||
|
emailAddress=''
|
||||||
|
PGPpubKey=''
|
||||||
xmppAddress=''
|
xmppAddress=''
|
||||||
matrixAddress=''
|
matrixAddress=''
|
||||||
manuallyApprovesFollowers=''
|
manuallyApprovesFollowers=''
|
||||||
|
@ -596,6 +600,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
||||||
donateUrl=getDonationUrl(actorJson)
|
donateUrl=getDonationUrl(actorJson)
|
||||||
xmppAddress=getXmppAddress(actorJson)
|
xmppAddress=getXmppAddress(actorJson)
|
||||||
matrixAddress=getMatrixAddress(actorJson)
|
matrixAddress=getMatrixAddress(actorJson)
|
||||||
|
emailAddress=getEmailAddress(actorJson)
|
||||||
|
PGPpubKey=getPGPpubKey(actorJson)
|
||||||
if actorJson.get('name'):
|
if actorJson.get('name'):
|
||||||
displayNickname=actorJson['name']
|
displayNickname=actorJson['name']
|
||||||
if actorJson.get('summary'):
|
if actorJson.get('summary'):
|
||||||
|
@ -721,6 +727,10 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
||||||
editProfileForm+=' <input type="text" name="xmppAddress" value="'+xmppAddress+'">'
|
editProfileForm+=' <input type="text" name="xmppAddress" value="'+xmppAddress+'">'
|
||||||
editProfileForm+='<label class="labels">Matrix</label><br>'
|
editProfileForm+='<label class="labels">Matrix</label><br>'
|
||||||
editProfileForm+=' <input type="text" name="matrixAddress" value="'+matrixAddress+'">'
|
editProfileForm+=' <input type="text" name="matrixAddress" value="'+matrixAddress+'">'
|
||||||
|
editProfileForm+='<label class="labels">Email</label><br>'
|
||||||
|
editProfileForm+=' <input type="text" name="email" value="'+emailAddress+'">'
|
||||||
|
editProfileForm+='<label class="labels">PGP</label><br>'
|
||||||
|
editProfileForm+=' <textarea id="message" name="pgp" style="height:100px">'+PGPpubKey+'</textarea>'
|
||||||
editProfileForm+=' </div>'
|
editProfileForm+=' </div>'
|
||||||
editProfileForm+=' <div class="container">'
|
editProfileForm+=' <div class="container">'
|
||||||
editProfileForm+=' <label class="labels">'+translate['The files attached below should be no larger than 10MB in total uploaded at once.']+'</label><br><br>'
|
editProfileForm+=' <label class="labels">'+translate['The files attached below should be no larger than 10MB in total uploaded at once.']+'</label><br><br>'
|
||||||
|
@ -1526,17 +1536,23 @@ def htmlProfile(defaultTimeline: str, \
|
||||||
|
|
||||||
donateSection=''
|
donateSection=''
|
||||||
donateUrl=getDonationUrl(profileJson)
|
donateUrl=getDonationUrl(profileJson)
|
||||||
|
PGPpubKey=getPGPpubKey(profileJson)
|
||||||
|
emailAddress=getEmailAddress(profileJson)
|
||||||
xmppAddress=getXmppAddress(profileJson)
|
xmppAddress=getXmppAddress(profileJson)
|
||||||
matrixAddress=getMatrixAddress(profileJson)
|
matrixAddress=getMatrixAddress(profileJson)
|
||||||
if donateUrl or xmppAddress or matrixAddress:
|
if donateUrl or xmppAddress or matrixAddress or PGPpubKey or emailAddress:
|
||||||
donateSection='<div class="container">\n'
|
donateSection='<div class="container">\n'
|
||||||
donateSection+=' <center>\n'
|
donateSection+=' <center>\n'
|
||||||
if donateUrl:
|
if donateUrl:
|
||||||
donateSection+=' <p><a href="'+donateUrl+'"><button class="donateButton">'+translate['Donate']+'</button></a></p>\n'
|
donateSection+=' <p><a href="'+donateUrl+'"><button class="donateButton">'+translate['Donate']+'</button></a></p>\n'
|
||||||
|
if emailAddress:
|
||||||
|
donateSection+='<p>Email: '+emailAddress+'</p>\n'
|
||||||
if xmppAddress:
|
if xmppAddress:
|
||||||
donateSection+='<p>XMPP: '+xmppAddress+'</p>\n'
|
donateSection+='<p>XMPP: '+xmppAddress+'</p>\n'
|
||||||
if matrixAddress:
|
if matrixAddress:
|
||||||
donateSection+='<p>Matrix: '+matrixAddress+'</p>\n'
|
donateSection+='<p>Matrix: '+matrixAddress+'</p>\n'
|
||||||
|
if PGPpubKey:
|
||||||
|
donateSection+='<p>PGP: '+PGPpubKey+'</p>\n'
|
||||||
donateSection+=' </center>\n'
|
donateSection+=' </center>\n'
|
||||||
donateSection+='</div>\n'
|
donateSection+='</div>\n'
|
||||||
|
|
||||||
|
@ -3340,7 +3356,9 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
||||||
pageNumber: int, \
|
pageNumber: int, \
|
||||||
donateUrl: str, \
|
donateUrl: str, \
|
||||||
xmppAddress: str, \
|
xmppAddress: str, \
|
||||||
matrixAddress: str) -> str:
|
matrixAddress: str, \
|
||||||
|
PGPpubKey: str, \
|
||||||
|
emailAddress) -> str:
|
||||||
"""Show options for a person: view/follow/block/report
|
"""Show options for a person: view/follow/block/report
|
||||||
"""
|
"""
|
||||||
optionsDomain,optionsPort=getDomainFromActor(optionsActor)
|
optionsDomain,optionsPort=getDomainFromActor(optionsActor)
|
||||||
|
@ -3397,10 +3415,14 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
||||||
optionsStr+=' <a href="'+optionsActor+'">'
|
optionsStr+=' <a href="'+optionsActor+'">'
|
||||||
optionsStr+=' <img loading="lazy" src="'+optionsProfileUrl+'"/></a>'
|
optionsStr+=' <img loading="lazy" src="'+optionsProfileUrl+'"/></a>'
|
||||||
optionsStr+=' <p class="optionsText">'+translate['Options for']+' @'+getNicknameFromActor(optionsActor)+'@'+optionsDomain+'</p>'
|
optionsStr+=' <p class="optionsText">'+translate['Options for']+' @'+getNicknameFromActor(optionsActor)+'@'+optionsDomain+'</p>'
|
||||||
|
if emailAddress:
|
||||||
|
optionsStr+='<p class="imText">Email: '+emailAddress+'</p>'
|
||||||
if xmppAddress:
|
if xmppAddress:
|
||||||
optionsStr+='<p class="imText">XMPP: '+xmppAddress+'</p>'
|
optionsStr+='<p class="imText">XMPP: '+xmppAddress+'</p>'
|
||||||
if matrixAddress:
|
if matrixAddress:
|
||||||
optionsStr+='<p class="imText">Matrix: '+matrixAddress+'</p>'
|
optionsStr+='<p class="imText">Matrix: '+matrixAddress+'</p>'
|
||||||
|
if PGPpubKey:
|
||||||
|
optionsStr+='<p class="imText">PGP: '+PGPpubKey+'</p>'
|
||||||
optionsStr+=' <form method="POST" action="'+originPathStr+'/personoptions">'
|
optionsStr+=' <form method="POST" action="'+originPathStr+'/personoptions">'
|
||||||
optionsStr+=' <input type="hidden" name="pageNumber" value="'+str(pageNumber)+'">'
|
optionsStr+=' <input type="hidden" name="pageNumber" value="'+str(pageNumber)+'">'
|
||||||
optionsStr+=' <input type="hidden" name="actor" value="'+optionsActor+'">'
|
optionsStr+=' <input type="hidden" name="actor" value="'+optionsActor+'">'
|
||||||
|
|
Loading…
Reference in New Issue