forked from indymedia/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 ssb import setSSBAddress
|
||||||
from tox import getToxAddress
|
from tox import getToxAddress
|
||||||
from tox import setToxAddress
|
from tox import setToxAddress
|
||||||
|
from briar import getBriarAddress
|
||||||
|
from briar import setBriarAddress
|
||||||
from jami import getJamiAddress
|
from jami import getJamiAddress
|
||||||
from jami import setJamiAddress
|
from jami import setJamiAddress
|
||||||
from matrix import getMatrixAddress
|
from matrix import getMatrixAddress
|
||||||
|
@ -4096,6 +4098,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
setToxAddress(actorJson, '')
|
setToxAddress(actorJson, '')
|
||||||
actorChanged = True
|
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
|
# change jami address
|
||||||
currentJamiAddress = getJamiAddress(actorJson)
|
currentJamiAddress = getJamiAddress(actorJson)
|
||||||
if fields.get('jamiAddress'):
|
if fields.get('jamiAddress'):
|
||||||
|
@ -5162,6 +5176,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
matrixAddress = None
|
matrixAddress = None
|
||||||
blogAddress = None
|
blogAddress = None
|
||||||
toxAddress = None
|
toxAddress = None
|
||||||
|
briarAddress = None
|
||||||
jamiAddress = None
|
jamiAddress = None
|
||||||
ssbAddress = None
|
ssbAddress = None
|
||||||
emailAddress = None
|
emailAddress = None
|
||||||
|
@ -5176,6 +5191,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
ssbAddress = getSSBAddress(actorJson)
|
ssbAddress = getSSBAddress(actorJson)
|
||||||
blogAddress = getBlogAddress(actorJson)
|
blogAddress = getBlogAddress(actorJson)
|
||||||
toxAddress = getToxAddress(actorJson)
|
toxAddress = getToxAddress(actorJson)
|
||||||
|
briarAddress = getBriarAddress(actorJson)
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actorJson)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actorJson)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actorJson)
|
||||||
|
@ -5192,7 +5208,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
pageNumber, donateUrl,
|
pageNumber, donateUrl,
|
||||||
xmppAddress, matrixAddress,
|
xmppAddress, matrixAddress,
|
||||||
ssbAddress, blogAddress,
|
ssbAddress, blogAddress,
|
||||||
toxAddress, jamiAddress,
|
toxAddress, briarAddress,
|
||||||
|
jamiAddress,
|
||||||
PGPpubKey, PGPfingerprint,
|
PGPpubKey, PGPfingerprint,
|
||||||
emailAddress,
|
emailAddress,
|
||||||
self.server.dormantMonths,
|
self.server.dormantMonths,
|
||||||
|
|
|
@ -39,6 +39,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
ssbAddress: str,
|
ssbAddress: str,
|
||||||
blogAddress: str,
|
blogAddress: str,
|
||||||
toxAddress: str,
|
toxAddress: str,
|
||||||
|
briarAddress: str,
|
||||||
jamiAddress: str,
|
jamiAddress: str,
|
||||||
PGPpubKey: str,
|
PGPpubKey: str,
|
||||||
PGPfingerprint: str,
|
PGPfingerprint: str,
|
||||||
|
@ -141,6 +142,9 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
if toxAddress:
|
if toxAddress:
|
||||||
optionsStr += \
|
optionsStr += \
|
||||||
'<p class="imText">Tox: ' + removeHtml(toxAddress) + '</p>\n'
|
'<p class="imText">Tox: ' + removeHtml(toxAddress) + '</p>\n'
|
||||||
|
if briarAddress:
|
||||||
|
optionsStr += \
|
||||||
|
'<p class="imText">Briar: ' + removeHtml(briarAddress) + '</p>\n'
|
||||||
if jamiAddress:
|
if jamiAddress:
|
||||||
optionsStr += \
|
optionsStr += \
|
||||||
'<p class="imText">Jami: ' + removeHtml(jamiAddress) + '</p>\n'
|
'<p class="imText">Jami: ' + removeHtml(jamiAddress) + '</p>\n'
|
||||||
|
|
|
@ -34,6 +34,7 @@ from pgp import getEmailAddress
|
||||||
from pgp import getPGPfingerprint
|
from pgp import getPGPfingerprint
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
from tox import getToxAddress
|
from tox import getToxAddress
|
||||||
|
from tox import getBriarAddress
|
||||||
from jami import getJamiAddress
|
from jami import getJamiAddress
|
||||||
from filters import isFiltered
|
from filters import isFiltered
|
||||||
from webapp_frontscreen import htmlFrontScreen
|
from webapp_frontscreen import htmlFrontScreen
|
||||||
|
@ -443,9 +444,11 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
matrixAddress = getMatrixAddress(profileJson)
|
matrixAddress = getMatrixAddress(profileJson)
|
||||||
ssbAddress = getSSBAddress(profileJson)
|
ssbAddress = getSSBAddress(profileJson)
|
||||||
toxAddress = getToxAddress(profileJson)
|
toxAddress = getToxAddress(profileJson)
|
||||||
|
briarAddress = getBriarAddress(profileJson)
|
||||||
jamiAddress = getJamiAddress(profileJson)
|
jamiAddress = getJamiAddress(profileJson)
|
||||||
if donateUrl or xmppAddress or matrixAddress or \
|
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:
|
PGPfingerprint or emailAddress:
|
||||||
donateSection = '<div class="container">\n'
|
donateSection = '<div class="container">\n'
|
||||||
donateSection += ' <center>\n'
|
donateSection += ' <center>\n'
|
||||||
|
@ -473,6 +476,10 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p>Tox: <label class="toxaddr">' + \
|
'<p>Tox: <label class="toxaddr">' + \
|
||||||
toxAddress + '</label></p>\n'
|
toxAddress + '</label></p>\n'
|
||||||
|
if briarAddress:
|
||||||
|
donateSection += \
|
||||||
|
'<p>Briar: <label class="toxaddr">' + \
|
||||||
|
briarAddress + '</label></p>\n'
|
||||||
if jamiAddress:
|
if jamiAddress:
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p>Jami: <label class="toxaddr">' + \
|
'<p>Jami: <label class="toxaddr">' + \
|
||||||
|
@ -877,6 +884,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
ssbAddress = ''
|
ssbAddress = ''
|
||||||
blogAddress = ''
|
blogAddress = ''
|
||||||
toxAddress = ''
|
toxAddress = ''
|
||||||
|
briarAddress = ''
|
||||||
manuallyApprovesFollowers = ''
|
manuallyApprovesFollowers = ''
|
||||||
actorJson = loadJson(actorFilename)
|
actorJson = loadJson(actorFilename)
|
||||||
if actorJson:
|
if actorJson:
|
||||||
|
@ -886,6 +894,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
ssbAddress = getSSBAddress(actorJson)
|
ssbAddress = getSSBAddress(actorJson)
|
||||||
blogAddress = getBlogAddress(actorJson)
|
blogAddress = getBlogAddress(actorJson)
|
||||||
toxAddress = getToxAddress(actorJson)
|
toxAddress = getToxAddress(actorJson)
|
||||||
|
briarAddress = getBriarAddress(actorJson)
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actorJson)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actorJson)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actorJson)
|
||||||
|
@ -1240,6 +1249,11 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
' <input type="text" name="toxAddress" value="' + \
|
' <input type="text" name="toxAddress" value="' + \
|
||||||
toxAddress + '">\n'
|
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 += '<label class="labels">Jami</label><br>\n'
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
' <input type="text" name="jamiAddress" value="' + \
|
' <input type="text" name="jamiAddress" value="' + \
|
||||||
|
|
Loading…
Reference in New Issue