forked from indymedia/epicyon
Tox address in profile
parent
494a9ea94c
commit
e5e6cad1b4
16
daemon.py
16
daemon.py
|
@ -34,6 +34,8 @@ from xmpp import getXmppAddress
|
|||
from xmpp import setXmppAddress
|
||||
from ssb import getSSBAddress
|
||||
from ssb import setSSBAddress
|
||||
from tox import getToxAddress
|
||||
from tox import setToxAddress
|
||||
from matrix import getMatrixAddress
|
||||
from matrix import setMatrixAddress
|
||||
from donate import getDonationUrl
|
||||
|
@ -1130,6 +1132,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
xmppAddress=getXmppAddress(actorJson)
|
||||
matrixAddress=getMatrixAddress(actorJson)
|
||||
ssbAddress=getSSBAddress(actorJson)
|
||||
toxAddress=getToxAddress(actorJson)
|
||||
emailAddress=getEmailAddress(actorJson)
|
||||
PGPpubKey=getPGPpubKey(actorJson)
|
||||
msg=htmlPersonOptions(self.server.translate, \
|
||||
|
@ -1141,7 +1144,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
optionsLink, \
|
||||
pageNumber,donateUrl, \
|
||||
xmppAddress,matrixAddress, \
|
||||
ssbAddress, \
|
||||
ssbAddress,toxAddress, \
|
||||
PGPpubKey,emailAddress).encode()
|
||||
self._set_headers('text/html',len(msg),cookie)
|
||||
self._write(msg)
|
||||
|
@ -4582,7 +4585,16 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
else:
|
||||
if currentSSBAddress:
|
||||
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)
|
||||
if fields.get('pgp'):
|
||||
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 xmpp import getXmppAddress
|
||||
from ssb import getSSBAddress
|
||||
from tox import getToxAddress
|
||||
from matrix import getMatrixAddress
|
||||
from donate import getDonationUrl
|
||||
from utils import isBlogPost
|
||||
|
@ -679,6 +680,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
|||
xmppAddress=''
|
||||
matrixAddress=''
|
||||
ssbAddress=''
|
||||
toxAddress=''
|
||||
manuallyApprovesFollowers=''
|
||||
actorJson=loadJson(actorFilename)
|
||||
if actorJson:
|
||||
|
@ -686,6 +688,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
|||
xmppAddress=getXmppAddress(actorJson)
|
||||
matrixAddress=getMatrixAddress(actorJson)
|
||||
ssbAddress=getSSBAddress(actorJson)
|
||||
toxAddress=getToxAddress(actorJson)
|
||||
emailAddress=getEmailAddress(actorJson)
|
||||
PGPpubKey=getPGPpubKey(actorJson)
|
||||
if actorJson.get('name'):
|
||||
|
@ -862,6 +865,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str, \
|
|||
editProfileForm+=' <input type="text" name="matrixAddress" value="'+matrixAddress+'">'
|
||||
editProfileForm+='<label class="labels">SSB</label><br>'
|
||||
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+=' <input type="text" name="email" value="'+emailAddress+'">'
|
||||
editProfileForm+='<label class="labels">'+translate['PGP']+'</label><br>'
|
||||
|
@ -1853,8 +1858,9 @@ def htmlProfile(defaultTimeline: str, \
|
|||
xmppAddress=getXmppAddress(profileJson)
|
||||
matrixAddress=getMatrixAddress(profileJson)
|
||||
ssbAddress=getSSBAddress(profileJson)
|
||||
toxAddress=getToxAddress(profileJson)
|
||||
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+=' <center>\n'
|
||||
if donateUrl:
|
||||
|
@ -1876,6 +1882,9 @@ def htmlProfile(defaultTimeline: str, \
|
|||
if ssbAddress:
|
||||
donateSection+= \
|
||||
'<p>SSB: <label class="ssbaddr">'+ssbAddress+'</label></p>\n'
|
||||
if toxAddress:
|
||||
donateSection+= \
|
||||
'<p>Tox: <label class="ssbaddr">'+toxAddress+'</label></p>\n'
|
||||
if PGPpubKey:
|
||||
donateSection+= \
|
||||
'<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>\n'
|
||||
|
@ -4303,6 +4312,7 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
|||
xmppAddress: str, \
|
||||
matrixAddress: str, \
|
||||
ssbAddress: str, \
|
||||
toxAddress: str, \
|
||||
PGPpubKey: str, \
|
||||
emailAddress) -> str:
|
||||
"""Show options for a person: view/follow/block/report
|
||||
|
@ -4379,6 +4389,9 @@ def htmlPersonOptions(translate: {},baseDir: str, \
|
|||
if ssbAddress:
|
||||
optionsStr+= \
|
||||
'<p class="imText">SSB: '+ssbAddress+'</p>'
|
||||
if toxAddress:
|
||||
optionsStr+= \
|
||||
'<p class="imText">Tox: '+toxAddress+'</p>'
|
||||
if PGPpubKey:
|
||||
optionsStr+='<p class="pgp">'+PGPpubKey.replace('\n','<br>')+'</p>'
|
||||
optionsStr+=' <form method="POST" action="'+originPathStr+'/personoptions">'
|
||||
|
|
Loading…
Reference in New Issue