forked from indymedia/epicyon
Tox address in profile
parent
494a9ea94c
commit
e5e6cad1b4
14
daemon.py
14
daemon.py
|
@ -34,6 +34,8 @@ from xmpp import getXmppAddress
|
||||||
from xmpp import setXmppAddress
|
from xmpp import setXmppAddress
|
||||||
from ssb import getSSBAddress
|
from ssb import getSSBAddress
|
||||||
from ssb import setSSBAddress
|
from ssb import setSSBAddress
|
||||||
|
from tox import getToxAddress
|
||||||
|
from tox import setToxAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
from matrix import setMatrixAddress
|
from matrix import setMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
|
@ -1130,6 +1132,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
xmppAddress=getXmppAddress(actorJson)
|
xmppAddress=getXmppAddress(actorJson)
|
||||||
matrixAddress=getMatrixAddress(actorJson)
|
matrixAddress=getMatrixAddress(actorJson)
|
||||||
ssbAddress=getSSBAddress(actorJson)
|
ssbAddress=getSSBAddress(actorJson)
|
||||||
|
toxAddress=getToxAddress(actorJson)
|
||||||
emailAddress=getEmailAddress(actorJson)
|
emailAddress=getEmailAddress(actorJson)
|
||||||
PGPpubKey=getPGPpubKey(actorJson)
|
PGPpubKey=getPGPpubKey(actorJson)
|
||||||
msg=htmlPersonOptions(self.server.translate, \
|
msg=htmlPersonOptions(self.server.translate, \
|
||||||
|
@ -1141,7 +1144,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
optionsLink, \
|
optionsLink, \
|
||||||
pageNumber,donateUrl, \
|
pageNumber,donateUrl, \
|
||||||
xmppAddress,matrixAddress, \
|
xmppAddress,matrixAddress, \
|
||||||
ssbAddress, \
|
ssbAddress,toxAddress, \
|
||||||
PGPpubKey,emailAddress).encode()
|
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)
|
||||||
|
@ -4583,6 +4586,15 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if currentSSBAddress:
|
if currentSSBAddress:
|
||||||
setSSBAddress(actorJson,'')
|
setSSBAddress(actorJson,'')
|
||||||
actorChanged=True
|
actorChanged=True
|
||||||
|
currentToxAddress=getToxAddress(actorJson)
|
||||||
|
if fields.get('toxAddress'):
|
||||||
|
if fields['toxAddress']!=currentToxAddress:
|
||||||
|
setToxAddress(actorJson,fields['toxAddress'])
|
||||||
|
actorChanged=True
|
||||||
|
else:
|
||||||
|
if currentToxAddress:
|
||||||
|
setToxAddress(actorJson,'')
|
||||||
|
actorChanged=True
|
||||||
currentPGPpubKey=getPGPpubKey(actorJson)
|
currentPGPpubKey=getPGPpubKey(actorJson)
|
||||||
if fields.get('pgp'):
|
if fields.get('pgp'):
|
||||||
if fields['pgp']!=currentPGPpubKey:
|
if fields['pgp']!=currentPGPpubKey:
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
__filename__ = "tox.py"
|
||||||
|
__author__ = "Bob Mottram"
|
||||||
|
__license__ = "AGPL3+"
|
||||||
|
__version__ = "1.1.0"
|
||||||
|
__maintainer__ = "Bob Mottram"
|
||||||
|
__email__ = "bob@freedombone.net"
|
||||||
|
__status__ = "Production"
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
def getToxAddress(actorJson: {}) -> str:
|
||||||
|
"""Returns tox 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('tox'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('type'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('value'):
|
||||||
|
continue
|
||||||
|
if propertyValue['type']!='PropertyValue':
|
||||||
|
continue
|
||||||
|
propertyValue['value']=propertyValue['value'].strip()
|
||||||
|
if len(propertyValue['value'])!=76:
|
||||||
|
continue
|
||||||
|
if propertyValue['value'].upper()!=propertyValue['value']:
|
||||||
|
continue
|
||||||
|
if '"' in propertyValue['value']:
|
||||||
|
continue
|
||||||
|
if ' ' in propertyValue['value']:
|
||||||
|
continue
|
||||||
|
if ',' in propertyValue['value']:
|
||||||
|
continue
|
||||||
|
if '.' in propertyValue['value']:
|
||||||
|
continue
|
||||||
|
return propertyValue['value']
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def setToxAddress(actorJson: {},toxAddress: str) -> None:
|
||||||
|
"""Sets an tox address for the given actor
|
||||||
|
"""
|
||||||
|
if not actorJson.get('attachment'):
|
||||||
|
actorJson['attachment']=[]
|
||||||
|
|
||||||
|
# remove any existing value
|
||||||
|
propertyFound=None
|
||||||
|
for propertyValue in actorJson['attachment']:
|
||||||
|
if not propertyValue.get('name'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('type'):
|
||||||
|
continue
|
||||||
|
if not propertyValue['name'].lower().startswith('tox'):
|
||||||
|
continue
|
||||||
|
propertyFound=propertyValue
|
||||||
|
break
|
||||||
|
if propertyFound:
|
||||||
|
actorJson['attachment'].remove(propertyFound)
|
||||||
|
|
||||||
|
if len(toxAddress)!=76:
|
||||||
|
return
|
||||||
|
if toxAddress.upper()!=toxAddress:
|
||||||
|
return
|
||||||
|
if '"' in toxAddress:
|
||||||
|
return
|
||||||
|
if ' ' in toxAddress:
|
||||||
|
return
|
||||||
|
if '.' in toxAddress:
|
||||||
|
return
|
||||||
|
if ',' in toxAddress:
|
||||||
|
return
|
||||||
|
|
||||||
|
for propertyValue in actorJson['attachment']:
|
||||||
|
if not propertyValue.get('name'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('type'):
|
||||||
|
continue
|
||||||
|
if not propertyValue['name'].lower().startswith('tox'):
|
||||||
|
continue
|
||||||
|
if propertyValue['type']!='PropertyValue':
|
||||||
|
continue
|
||||||
|
propertyValue['value']=toxAddress
|
||||||
|
return
|
||||||
|
|
||||||
|
newToxAddress={
|
||||||
|
"name": "Tox",
|
||||||
|
"type": "PropertyValue",
|
||||||
|
"value": toxAddress
|
||||||
|
}
|
||||||
|
actorJson['attachment'].append(newToxAddress)
|
|
@ -22,6 +22,7 @@ from pgp import getEmailAddress
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
from xmpp import getXmppAddress
|
from xmpp import getXmppAddress
|
||||||
from ssb import getSSBAddress
|
from ssb import getSSBAddress
|
||||||
|
from tox import getToxAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
from donate import getDonationUrl
|
from donate import getDonationUrl
|
||||||
from utils import isBlogPost
|
from utils import isBlogPost
|
||||||
|
@ -679,6 +680,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
||||||
xmppAddress=''
|
xmppAddress=''
|
||||||
matrixAddress=''
|
matrixAddress=''
|
||||||
ssbAddress=''
|
ssbAddress=''
|
||||||
|
toxAddress=''
|
||||||
manuallyApprovesFollowers=''
|
manuallyApprovesFollowers=''
|
||||||
actorJson=loadJson(actorFilename)
|
actorJson=loadJson(actorFilename)
|
||||||
if actorJson:
|
if actorJson:
|
||||||
|
@ -686,6 +688,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
||||||
xmppAddress=getXmppAddress(actorJson)
|
xmppAddress=getXmppAddress(actorJson)
|
||||||
matrixAddress=getMatrixAddress(actorJson)
|
matrixAddress=getMatrixAddress(actorJson)
|
||||||
ssbAddress=getSSBAddress(actorJson)
|
ssbAddress=getSSBAddress(actorJson)
|
||||||
|
toxAddress=getToxAddress(actorJson)
|
||||||
emailAddress=getEmailAddress(actorJson)
|
emailAddress=getEmailAddress(actorJson)
|
||||||
PGPpubKey=getPGPpubKey(actorJson)
|
PGPpubKey=getPGPpubKey(actorJson)
|
||||||
if actorJson.get('name'):
|
if actorJson.get('name'):
|
||||||
|
@ -862,6 +865,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
||||||
editProfileForm+=' <input type="text" name="matrixAddress" value="'+matrixAddress+'">'
|
editProfileForm+=' <input type="text" name="matrixAddress" value="'+matrixAddress+'">'
|
||||||
editProfileForm+='<label class="labels">SSB</label><br>'
|
editProfileForm+='<label class="labels">SSB</label><br>'
|
||||||
editProfileForm+=' <input type="text" name="ssbAddress" value="'+ssbAddress+'">'
|
editProfileForm+=' <input type="text" name="ssbAddress" value="'+ssbAddress+'">'
|
||||||
|
editProfileForm+='<label class="labels">Tox</label><br>'
|
||||||
|
editProfileForm+=' <input type="text" name="toxAddress" value="'+toxAddress+'">'
|
||||||
editProfileForm+='<label class="labels">'+translate['Email']+'</label><br>'
|
editProfileForm+='<label class="labels">'+translate['Email']+'</label><br>'
|
||||||
editProfileForm+=' <input type="text" name="email" value="'+emailAddress+'">'
|
editProfileForm+=' <input type="text" name="email" value="'+emailAddress+'">'
|
||||||
editProfileForm+='<label class="labels">'+translate['PGP']+'</label><br>'
|
editProfileForm+='<label class="labels">'+translate['PGP']+'</label><br>'
|
||||||
|
@ -1853,8 +1858,9 @@ def htmlProfile(defaultTimeline: str, \
|
||||||
xmppAddress=getXmppAddress(profileJson)
|
xmppAddress=getXmppAddress(profileJson)
|
||||||
matrixAddress=getMatrixAddress(profileJson)
|
matrixAddress=getMatrixAddress(profileJson)
|
||||||
ssbAddress=getSSBAddress(profileJson)
|
ssbAddress=getSSBAddress(profileJson)
|
||||||
|
toxAddress=getToxAddress(profileJson)
|
||||||
if donateUrl or xmppAddress or matrixAddress or \
|
if donateUrl or xmppAddress or matrixAddress or \
|
||||||
ssbAddress or PGPpubKey or emailAddress:
|
ssbAddress or toxAddress or PGPpubKey or emailAddress:
|
||||||
donateSection='<div class="container">\n'
|
donateSection='<div class="container">\n'
|
||||||
donateSection+=' <center>\n'
|
donateSection+=' <center>\n'
|
||||||
if donateUrl:
|
if donateUrl:
|
||||||
|
@ -1876,6 +1882,9 @@ def htmlProfile(defaultTimeline: str, \
|
||||||
if ssbAddress:
|
if ssbAddress:
|
||||||
donateSection+= \
|
donateSection+= \
|
||||||
'<p>SSB: <label class="ssbaddr">'+ssbAddress+'</label></p>\n'
|
'<p>SSB: <label class="ssbaddr">'+ssbAddress+'</label></p>\n'
|
||||||
|
if toxAddress:
|
||||||
|
donateSection+= \
|
||||||
|
'<p>Tox: <label class="ssbaddr">'+toxAddress+'</label></p>\n'
|
||||||
if PGPpubKey:
|
if PGPpubKey:
|
||||||
donateSection+= \
|
donateSection+= \
|
||||||
'<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>\n'
|
'<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>\n'
|
||||||
|
@ -4303,6 +4312,7 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
||||||
xmppAddress: str, \
|
xmppAddress: str, \
|
||||||
matrixAddress: str, \
|
matrixAddress: str, \
|
||||||
ssbAddress: str, \
|
ssbAddress: str, \
|
||||||
|
toxAddress: str, \
|
||||||
PGPpubKey: str, \
|
PGPpubKey: str, \
|
||||||
emailAddress) -> str:
|
emailAddress) -> str:
|
||||||
"""Show options for a person: view/follow/block/report
|
"""Show options for a person: view/follow/block/report
|
||||||
|
@ -4379,6 +4389,9 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
||||||
if ssbAddress:
|
if ssbAddress:
|
||||||
optionsStr+= \
|
optionsStr+= \
|
||||||
'<p class="imText">SSB: '+ssbAddress+'</p>'
|
'<p class="imText">SSB: '+ssbAddress+'</p>'
|
||||||
|
if toxAddress:
|
||||||
|
optionsStr+= \
|
||||||
|
'<p class="imText">Tox: '+toxAddress+'</p>'
|
||||||
if PGPpubKey:
|
if PGPpubKey:
|
||||||
optionsStr+='<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>'
|
optionsStr+='<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>'
|
||||||
optionsStr+=' <form method="POST" action="'+originPathStr+'/personoptions">'
|
optionsStr+=' <form method="POST" action="'+originPathStr+'/personoptions">'
|
||||||
|
|
Loading…
Reference in New Issue