mirror of https://gitlab.com/bashrc2/epicyon
Add briar address to profile
parent
27f797c8af
commit
0401708c5d
|
@ -0,0 +1,99 @@
|
|||
__filename__ = "briar.py"
|
||||
__author__ = "Bob Mottram"
|
||||
__license__ = "AGPL3+"
|
||||
__version__ = "1.1.0"
|
||||
__maintainer__ = "Bob Mottram"
|
||||
__email__ = "bob@freedombone.net"
|
||||
__status__ = "Production"
|
||||
|
||||
|
||||
def getBriarAddress(actorJson: {}) -> str:
|
||||
"""Returns briar 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('briar'):
|
||||
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']) < 50:
|
||||
continue
|
||||
if propertyValue['value'].lower() != 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 setBriarAddress(actorJson: {}, briarAddress: str) -> None:
|
||||
"""Sets an briar address for the given actor
|
||||
"""
|
||||
notBriarAddress = False
|
||||
|
||||
if len(briarAddress) < 50:
|
||||
notBriarAddress = True
|
||||
if briarAddress.lower() != briarAddress:
|
||||
notBriarAddress = True
|
||||
if '"' in briarAddress:
|
||||
notBriarAddress = True
|
||||
if ' ' in briarAddress:
|
||||
notBriarAddress = True
|
||||
if '.' in briarAddress:
|
||||
notBriarAddress = True
|
||||
if ',' in briarAddress:
|
||||
notBriarAddress = True
|
||||
if '<' in briarAddress:
|
||||
notBriarAddress = 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('briar'):
|
||||
continue
|
||||
propertyFound = propertyValue
|
||||
break
|
||||
if propertyFound:
|
||||
actorJson['attachment'].remove(propertyFound)
|
||||
if notBriarAddress:
|
||||
return
|
||||
|
||||
for propertyValue in actorJson['attachment']:
|
||||
if not propertyValue.get('name'):
|
||||
continue
|
||||
if not propertyValue.get('type'):
|
||||
continue
|
||||
if not propertyValue['name'].lower().startswith('briar'):
|
||||
continue
|
||||
if propertyValue['type'] != 'PropertyValue':
|
||||
continue
|
||||
propertyValue['value'] = briarAddress
|
||||
return
|
||||
|
||||
newBriarAddress = {
|
||||
"name": "Briar",
|
||||
"type": "PropertyValue",
|
||||
"value": briarAddress
|
||||
}
|
||||
actorJson['attachment'].append(newBriarAddress)
|
19
daemon.py
19
daemon.py
|
@ -39,6 +39,8 @@ from ssb import getSSBAddress
|
|||
from ssb import setSSBAddress
|
||||
from tox import getToxAddress
|
||||
from tox import setToxAddress
|
||||
from briar import getBriarAddress
|
||||
from briar import setBriarAddress
|
||||
from jami import getJamiAddress
|
||||
from jami import setJamiAddress
|
||||
from matrix import getMatrixAddress
|
||||
|
@ -4096,6 +4098,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
setToxAddress(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# change briar address
|
||||
currentBriarAddress = getBriarAddress(actorJson)
|
||||
if fields.get('briarAddress'):
|
||||
if fields['briarAddress'] != currentBriarAddress:
|
||||
setBriarAddress(actorJson,
|
||||
fields['briarAddress'])
|
||||
actorChanged = True
|
||||
else:
|
||||
if currentBriarAddress:
|
||||
setBriarAddress(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# change jami address
|
||||
currentJamiAddress = getJamiAddress(actorJson)
|
||||
if fields.get('jamiAddress'):
|
||||
|
@ -5162,6 +5176,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
matrixAddress = None
|
||||
blogAddress = None
|
||||
toxAddress = None
|
||||
briarAddress = None
|
||||
jamiAddress = None
|
||||
ssbAddress = None
|
||||
emailAddress = None
|
||||
|
@ -5176,6 +5191,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
ssbAddress = getSSBAddress(actorJson)
|
||||
blogAddress = getBlogAddress(actorJson)
|
||||
toxAddress = getToxAddress(actorJson)
|
||||
briarAddress = getBriarAddress(actorJson)
|
||||
jamiAddress = getJamiAddress(actorJson)
|
||||
emailAddress = getEmailAddress(actorJson)
|
||||
PGPpubKey = getPGPpubKey(actorJson)
|
||||
|
@ -5192,7 +5208,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
pageNumber, donateUrl,
|
||||
xmppAddress, matrixAddress,
|
||||
ssbAddress, blogAddress,
|
||||
toxAddress, jamiAddress,
|
||||
toxAddress, briarAddress,
|
||||
jamiAddress,
|
||||
PGPpubKey, PGPfingerprint,
|
||||
emailAddress,
|
||||
self.server.dormantMonths,
|
||||
|
|
|
@ -39,6 +39,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
ssbAddress: str,
|
||||
blogAddress: str,
|
||||
toxAddress: str,
|
||||
briarAddress: str,
|
||||
jamiAddress: str,
|
||||
PGPpubKey: str,
|
||||
PGPfingerprint: str,
|
||||
|
@ -141,6 +142,9 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
if toxAddress:
|
||||
optionsStr += \
|
||||
'<p class="imText">Tox: ' + removeHtml(toxAddress) + '</p>\n'
|
||||
if briarAddress:
|
||||
optionsStr += \
|
||||
'<p class="imText">Briar: ' + removeHtml(briarAddress) + '</p>\n'
|
||||
if jamiAddress:
|
||||
optionsStr += \
|
||||
'<p class="imText">Jami: ' + removeHtml(jamiAddress) + '</p>\n'
|
||||
|
|
|
@ -34,6 +34,7 @@ from pgp import getEmailAddress
|
|||
from pgp import getPGPfingerprint
|
||||
from pgp import getPGPpubKey
|
||||
from tox import getToxAddress
|
||||
from tox import getBriarAddress
|
||||
from jami import getJamiAddress
|
||||
from filters import isFiltered
|
||||
from webapp_frontscreen import htmlFrontScreen
|
||||
|
@ -443,9 +444,11 @@ def htmlProfile(rssIconAtTop: bool,
|
|||
matrixAddress = getMatrixAddress(profileJson)
|
||||
ssbAddress = getSSBAddress(profileJson)
|
||||
toxAddress = getToxAddress(profileJson)
|
||||
briarAddress = getBriarAddress(profileJson)
|
||||
jamiAddress = getJamiAddress(profileJson)
|
||||
if donateUrl or xmppAddress or matrixAddress or \
|
||||
ssbAddress or toxAddress or jamiAddress or PGPpubKey or \
|
||||
ssbAddress or toxAddress or briarAddress or \
|
||||
jamiAddress or PGPpubKey or \
|
||||
PGPfingerprint or emailAddress:
|
||||
donateSection = '<div class="container">\n'
|
||||
donateSection += ' <center>\n'
|
||||
|
@ -473,6 +476,10 @@ def htmlProfile(rssIconAtTop: bool,
|
|||
donateSection += \
|
||||
'<p>Tox: <label class="toxaddr">' + \
|
||||
toxAddress + '</label></p>\n'
|
||||
if briarAddress:
|
||||
donateSection += \
|
||||
'<p>Briar: <label class="toxaddr">' + \
|
||||
briarAddress + '</label></p>\n'
|
||||
if jamiAddress:
|
||||
donateSection += \
|
||||
'<p>Jami: <label class="toxaddr">' + \
|
||||
|
@ -877,6 +884,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
ssbAddress = ''
|
||||
blogAddress = ''
|
||||
toxAddress = ''
|
||||
briarAddress = ''
|
||||
manuallyApprovesFollowers = ''
|
||||
actorJson = loadJson(actorFilename)
|
||||
if actorJson:
|
||||
|
@ -886,6 +894,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
ssbAddress = getSSBAddress(actorJson)
|
||||
blogAddress = getBlogAddress(actorJson)
|
||||
toxAddress = getToxAddress(actorJson)
|
||||
briarAddress = getBriarAddress(actorJson)
|
||||
jamiAddress = getJamiAddress(actorJson)
|
||||
emailAddress = getEmailAddress(actorJson)
|
||||
PGPpubKey = getPGPpubKey(actorJson)
|
||||
|
@ -1240,6 +1249,11 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
' <input type="text" name="toxAddress" value="' + \
|
||||
toxAddress + '">\n'
|
||||
|
||||
editProfileForm += '<label class="labels">Briar</label><br>\n'
|
||||
editProfileForm += \
|
||||
' <input type="text" name="briarAddress" value="' + \
|
||||
briarAddress + '">\n'
|
||||
|
||||
editProfileForm += '<label class="labels">Jami</label><br>\n'
|
||||
editProfileForm += \
|
||||
' <input type="text" name="jamiAddress" value="' + \
|
||||
|
|
Loading…
Reference in New Issue