mirror of https://gitlab.com/bashrc2/epicyon
Add jami address to profile
parent
cab122e47d
commit
c9b0d113ab
18
daemon.py
18
daemon.py
|
@ -40,6 +40,8 @@ from ssb import getSSBAddress
|
|||
from ssb import setSSBAddress
|
||||
from tox import getToxAddress
|
||||
from tox import setToxAddress
|
||||
from jami import getJamiAddress
|
||||
from jami import setJamiAddress
|
||||
from matrix import getMatrixAddress
|
||||
from matrix import setMatrixAddress
|
||||
from donate import getDonationUrl
|
||||
|
@ -3787,6 +3789,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
setToxAddress(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# change jami address
|
||||
currentJamiAddress = getJamiAddress(actorJson)
|
||||
if fields.get('jamiAddress'):
|
||||
if fields['jamiAddress'] != currentJamiAddress:
|
||||
setJamiAddress(actorJson,
|
||||
fields['jamiAddress'])
|
||||
actorChanged = True
|
||||
else:
|
||||
if currentJamiAddress:
|
||||
setJamiAddress(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# change PGP public key
|
||||
currentPGPpubKey = getPGPpubKey(actorJson)
|
||||
if fields.get('pgp'):
|
||||
|
@ -4747,6 +4761,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
matrixAddress = None
|
||||
blogAddress = None
|
||||
toxAddress = None
|
||||
jamiAddress = None
|
||||
ssbAddress = None
|
||||
emailAddress = None
|
||||
actorJson = getPersonFromCache(baseDir,
|
||||
|
@ -4760,6 +4775,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
ssbAddress = getSSBAddress(actorJson)
|
||||
blogAddress = getBlogAddress(actorJson)
|
||||
toxAddress = getToxAddress(actorJson)
|
||||
jamiAddress = getJamiAddress(actorJson)
|
||||
emailAddress = getEmailAddress(actorJson)
|
||||
PGPpubKey = getPGPpubKey(actorJson)
|
||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
||||
|
@ -4775,7 +4791,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pageNumber, donateUrl,
|
||||
xmppAddress, matrixAddress,
|
||||
ssbAddress, blogAddress,
|
||||
toxAddress,
|
||||
toxAddress, jamiAddress,
|
||||
PGPpubKey, PGPfingerprint,
|
||||
emailAddress).encode('utf-8')
|
||||
self._set_headers('text/html', len(msg),
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
__filename__ = "jami.py"
|
||||
__author__ = "Bob Mottram"
|
||||
__license__ = "AGPL3+"
|
||||
__version__ = "1.1.0"
|
||||
__maintainer__ = "Bob Mottram"
|
||||
__email__ = "bob@freedombone.net"
|
||||
__status__ = "Production"
|
||||
|
||||
|
||||
def getJamiAddress(actorJson: {}) -> str:
|
||||
"""Returns jami 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('jami'):
|
||||
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']) < 2:
|
||||
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 setJamiAddress(actorJson: {}, jamiAddress: str) -> None:
|
||||
"""Sets an jami address for the given actor
|
||||
"""
|
||||
notJamiAddress = False
|
||||
|
||||
if len(jamiAddress) < 2:
|
||||
notJamiAddress = True
|
||||
if '"' in jamiAddress:
|
||||
notJamiAddress = True
|
||||
if ' ' in jamiAddress:
|
||||
notJamiAddress = True
|
||||
if '.' in jamiAddress:
|
||||
notJamiAddress = True
|
||||
if ',' in jamiAddress:
|
||||
notJamiAddress = True
|
||||
|
||||
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('jami'):
|
||||
continue
|
||||
propertyFound = propertyValue
|
||||
break
|
||||
if propertyFound:
|
||||
actorJson['attachment'].remove(propertyFound)
|
||||
if notJamiAddress:
|
||||
return
|
||||
|
||||
for propertyValue in actorJson['attachment']:
|
||||
if not propertyValue.get('name'):
|
||||
continue
|
||||
if not propertyValue.get('type'):
|
||||
continue
|
||||
if not propertyValue['name'].lower().startswith('jami'):
|
||||
continue
|
||||
if propertyValue['type'] != 'PropertyValue':
|
||||
continue
|
||||
propertyValue['value'] = jamiAddress
|
||||
return
|
||||
|
||||
newJamiAddress = {
|
||||
"name": "Jami",
|
||||
"type": "PropertyValue",
|
||||
"value": jamiAddress
|
||||
}
|
||||
actorJson['attachment'].append(newJamiAddress)
|
|
@ -34,6 +34,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
ssbAddress: str,
|
||||
blogAddress: str,
|
||||
toxAddress: str,
|
||||
jamiAddress: str,
|
||||
PGPpubKey: str,
|
||||
PGPfingerprint: str,
|
||||
emailAddress) -> str:
|
||||
|
@ -131,6 +132,9 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
if toxAddress:
|
||||
optionsStr += \
|
||||
'<p class="imText">Tox: ' + toxAddress + '</p>\n'
|
||||
if jamiAddress:
|
||||
optionsStr += \
|
||||
'<p class="imText">Jami: ' + jamiAddress + '</p>\n'
|
||||
if PGPfingerprint:
|
||||
optionsStr += '<p class="pgp">PGP: ' + \
|
||||
PGPfingerprint.replace('\n', '<br>') + '</p>\n'
|
||||
|
|
|
@ -31,6 +31,7 @@ from pgp import getEmailAddress
|
|||
from pgp import getPGPfingerprint
|
||||
from pgp import getPGPpubKey
|
||||
from tox import getToxAddress
|
||||
from jami import getJamiAddress
|
||||
from webapp_frontscreen import htmlFrontScreen
|
||||
from webapp_utils import scheduledPostsExist
|
||||
from webapp_utils import getPersonAvatarUrl
|
||||
|
@ -436,8 +437,9 @@ def htmlProfile(rssIconAtTop: bool,
|
|||
matrixAddress = getMatrixAddress(profileJson)
|
||||
ssbAddress = getSSBAddress(profileJson)
|
||||
toxAddress = getToxAddress(profileJson)
|
||||
jamiAddress = getJamiAddress(profileJson)
|
||||
if donateUrl or xmppAddress or matrixAddress or \
|
||||
ssbAddress or toxAddress or PGPpubKey or \
|
||||
ssbAddress or toxAddress or jamiAddress or PGPpubKey or \
|
||||
PGPfingerprint or emailAddress:
|
||||
donateSection = '<div class="container">\n'
|
||||
donateSection += ' <center>\n'
|
||||
|
@ -465,6 +467,10 @@ def htmlProfile(rssIconAtTop: bool,
|
|||
donateSection += \
|
||||
'<p>Tox: <label class="toxaddr">' + \
|
||||
toxAddress + '</label></p>\n'
|
||||
if jamiAddress:
|
||||
donateSection += \
|
||||
'<p>Jami: <label class="toxaddr">' + \
|
||||
jamiAddress + '</label></p>\n'
|
||||
if PGPfingerprint:
|
||||
donateSection += \
|
||||
'<p class="pgp">PGP: ' + \
|
||||
|
@ -863,6 +869,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
ssbAddress = getSSBAddress(actorJson)
|
||||
blogAddress = getBlogAddress(actorJson)
|
||||
toxAddress = getToxAddress(actorJson)
|
||||
jamiAddress = getJamiAddress(actorJson)
|
||||
emailAddress = getEmailAddress(actorJson)
|
||||
PGPpubKey = getPGPpubKey(actorJson)
|
||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
||||
|
@ -1194,6 +1201,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
editProfileForm += \
|
||||
' <input type="text" name="toxAddress" value="' + \
|
||||
toxAddress + '">\n'
|
||||
|
||||
editProfileForm += '<label class="labels">Jami</label><br>\n'
|
||||
editProfileForm += \
|
||||
' <input type="text" name="jamiAddress" value="' + \
|
||||
jamiAddress + '">\n'
|
||||
|
||||
editProfileForm += '<label class="labels">' + \
|
||||
translate['Email'] + '</label><br>\n'
|
||||
editProfileForm += \
|
||||
|
|
Loading…
Reference in New Issue