mirror of https://gitlab.com/bashrc2/epicyon
Support for enigma-reloaded public key
parent
10a215c71c
commit
aa709f7e24
17
daemon.py
17
daemon.py
|
@ -29,6 +29,8 @@ from webfinger import webfingerUpdate
|
||||||
from mastoapiv1 import mastoApiV1Response
|
from mastoapiv1 import mastoApiV1Response
|
||||||
from metadata import metaDataNodeInfo
|
from metadata import metaDataNodeInfo
|
||||||
from metadata import metadataCustomEmoji
|
from metadata import metadataCustomEmoji
|
||||||
|
from enigma import getEnigmaPubKey
|
||||||
|
from enigma import setEnigmaPubKey
|
||||||
from pgp import getEmailAddress
|
from pgp import getEmailAddress
|
||||||
from pgp import setEmailAddress
|
from pgp import setEmailAddress
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
|
@ -5379,6 +5381,18 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
setCwtchAddress(actorJson, '')
|
setCwtchAddress(actorJson, '')
|
||||||
actorChanged = True
|
actorChanged = True
|
||||||
|
|
||||||
|
# change Enigma public key
|
||||||
|
currentEnigmaPubKey = getEnigmaPubKey(actorJson)
|
||||||
|
if fields.get('enigmapubkey'):
|
||||||
|
if fields['enigmapubkey'] != currentEnigmaPubKey:
|
||||||
|
setEnigmaPubKey(actorJson,
|
||||||
|
fields['enigmapubkey'])
|
||||||
|
actorChanged = True
|
||||||
|
else:
|
||||||
|
if currentEnigmaPubKey:
|
||||||
|
setEnigmaPubKey(actorJson, '')
|
||||||
|
actorChanged = True
|
||||||
|
|
||||||
# change PGP public key
|
# change PGP public key
|
||||||
currentPGPpubKey = getPGPpubKey(actorJson)
|
currentPGPpubKey = getPGPpubKey(actorJson)
|
||||||
if fields.get('pgp'):
|
if fields.get('pgp'):
|
||||||
|
@ -7039,6 +7053,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
isGroup = False
|
isGroup = False
|
||||||
donateUrl = None
|
donateUrl = None
|
||||||
websiteUrl = None
|
websiteUrl = None
|
||||||
|
EnigmaPubKey = None
|
||||||
PGPpubKey = None
|
PGPpubKey = None
|
||||||
PGPfingerprint = None
|
PGPfingerprint = None
|
||||||
xmppAddress = None
|
xmppAddress = None
|
||||||
|
@ -7076,6 +7091,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actorJson)
|
||||||
cwtchAddress = getCwtchAddress(actorJson)
|
cwtchAddress = getCwtchAddress(actorJson)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actorJson)
|
||||||
|
EnigmaPubKey = getEnigmaPubKey(actorJson)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actorJson)
|
||||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
PGPfingerprint = getPGPfingerprint(actorJson)
|
||||||
if actorJson.get('alsoKnownAs'):
|
if actorJson.get('alsoKnownAs'):
|
||||||
|
@ -7110,6 +7126,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
ssbAddress, blogAddress,
|
ssbAddress, blogAddress,
|
||||||
toxAddress, briarAddress,
|
toxAddress, briarAddress,
|
||||||
jamiAddress, cwtchAddress,
|
jamiAddress, cwtchAddress,
|
||||||
|
EnigmaPubKey,
|
||||||
PGPpubKey, PGPfingerprint,
|
PGPpubKey, PGPfingerprint,
|
||||||
emailAddress,
|
emailAddress,
|
||||||
self.server.dormantMonths,
|
self.server.dormantMonths,
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
__filename__ = "enigma.py"
|
||||||
|
__author__ = "Bob Mottram"
|
||||||
|
__license__ = "AGPL3+"
|
||||||
|
__version__ = "1.2.0"
|
||||||
|
__maintainer__ = "Bob Mottram"
|
||||||
|
__email__ = "bob@libreserver.org"
|
||||||
|
__status__ = "Production"
|
||||||
|
__module_group__ = "Profile Metadata"
|
||||||
|
|
||||||
|
|
||||||
|
def getEnigmaPubKey(actorJson: {}) -> str:
|
||||||
|
"""Returns Enigma public key 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('enigma'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('type'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('value'):
|
||||||
|
continue
|
||||||
|
if propertyValue['type'] != 'PropertyValue':
|
||||||
|
continue
|
||||||
|
return propertyValue['value']
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def setEnigmaPubKey(actorJson: {}, enigmaPubKey: str) -> None:
|
||||||
|
"""Sets a Enigma public key for the given actor
|
||||||
|
"""
|
||||||
|
removeKey = False
|
||||||
|
if not enigmaPubKey:
|
||||||
|
removeKey = 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('enigma'):
|
||||||
|
continue
|
||||||
|
propertyFound = propertyValue
|
||||||
|
break
|
||||||
|
if propertyFound:
|
||||||
|
actorJson['attachment'].remove(propertyValue)
|
||||||
|
if removeKey:
|
||||||
|
return
|
||||||
|
|
||||||
|
for propertyValue in actorJson['attachment']:
|
||||||
|
if not propertyValue.get('name'):
|
||||||
|
continue
|
||||||
|
if not propertyValue.get('type'):
|
||||||
|
continue
|
||||||
|
if not propertyValue['name'].lower().startswith('enigma'):
|
||||||
|
continue
|
||||||
|
if propertyValue['type'] != 'PropertyValue':
|
||||||
|
continue
|
||||||
|
propertyValue['value'] = enigmaPubKey
|
||||||
|
return
|
||||||
|
|
||||||
|
newenigmaPubKey = {
|
||||||
|
"name": "Enigma",
|
||||||
|
"type": "PropertyValue",
|
||||||
|
"value": enigmaPubKey
|
||||||
|
}
|
||||||
|
actorJson['attachment'].append(newenigmaPubKey)
|
|
@ -49,6 +49,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
briarAddress: str,
|
briarAddress: str,
|
||||||
jamiAddress: str,
|
jamiAddress: str,
|
||||||
cwtchAddress: str,
|
cwtchAddress: str,
|
||||||
|
EnigmaPubKey: str,
|
||||||
PGPpubKey: str,
|
PGPpubKey: str,
|
||||||
PGPfingerprint: str,
|
PGPfingerprint: str,
|
||||||
emailAddress: str,
|
emailAddress: str,
|
||||||
|
@ -226,6 +227,9 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
if cwtchAddress:
|
if cwtchAddress:
|
||||||
optionsStr += \
|
optionsStr += \
|
||||||
'<p class="imText">Cwtch: ' + removeHtml(cwtchAddress) + '</p>\n'
|
'<p class="imText">Cwtch: ' + removeHtml(cwtchAddress) + '</p>\n'
|
||||||
|
if EnigmaPubKey:
|
||||||
|
optionsStr += \
|
||||||
|
'<p class="imText">Enigma: ' + removeHtml(EnigmaPubKey) + '</p>\n'
|
||||||
if PGPfingerprint:
|
if PGPfingerprint:
|
||||||
optionsStr += '<p class="pgp">PGP: ' + \
|
optionsStr += '<p class="pgp">PGP: ' + \
|
||||||
removeHtml(PGPfingerprint).replace('\n', '<br>') + '</p>\n'
|
removeHtml(PGPfingerprint).replace('\n', '<br>') + '</p>\n'
|
||||||
|
|
|
@ -47,6 +47,7 @@ from ssb import getSSBAddress
|
||||||
from pgp import getEmailAddress
|
from pgp import getEmailAddress
|
||||||
from pgp import getPGPfingerprint
|
from pgp import getPGPfingerprint
|
||||||
from pgp import getPGPpubKey
|
from pgp import getPGPpubKey
|
||||||
|
from enigma import getEnigmaPubKey
|
||||||
from tox import getToxAddress
|
from tox import getToxAddress
|
||||||
from briar import getBriarAddress
|
from briar import getBriarAddress
|
||||||
from jami import getJamiAddress
|
from jami import getJamiAddress
|
||||||
|
@ -631,6 +632,7 @@ def htmlProfile(signingPrivateKeyPem: str,
|
||||||
donateUrl = getDonationUrl(profileJson)
|
donateUrl = getDonationUrl(profileJson)
|
||||||
websiteUrl = getWebsite(profileJson, translate)
|
websiteUrl = getWebsite(profileJson, translate)
|
||||||
blogAddress = getBlogAddress(profileJson)
|
blogAddress = getBlogAddress(profileJson)
|
||||||
|
EnigmaPubKey = getEnigmaPubKey(profileJson)
|
||||||
PGPpubKey = getPGPpubKey(profileJson)
|
PGPpubKey = getPGPpubKey(profileJson)
|
||||||
PGPfingerprint = getPGPfingerprint(profileJson)
|
PGPfingerprint = getPGPfingerprint(profileJson)
|
||||||
emailAddress = getEmailAddress(profileJson)
|
emailAddress = getEmailAddress(profileJson)
|
||||||
|
@ -643,7 +645,7 @@ def htmlProfile(signingPrivateKeyPem: str,
|
||||||
cwtchAddress = getCwtchAddress(profileJson)
|
cwtchAddress = getCwtchAddress(profileJson)
|
||||||
if donateUrl or websiteUrl or xmppAddress or matrixAddress or \
|
if donateUrl or websiteUrl or xmppAddress or matrixAddress or \
|
||||||
ssbAddress or toxAddress or briarAddress or \
|
ssbAddress or toxAddress or briarAddress or \
|
||||||
jamiAddress or cwtchAddress or PGPpubKey or \
|
jamiAddress or cwtchAddress or PGPpubKey or EnigmaPubKey or \
|
||||||
PGPfingerprint or emailAddress:
|
PGPfingerprint or emailAddress:
|
||||||
donateSection = '<div class="container">\n'
|
donateSection = '<div class="container">\n'
|
||||||
donateSection += ' <center>\n'
|
donateSection += ' <center>\n'
|
||||||
|
@ -696,6 +698,10 @@ def htmlProfile(signingPrivateKeyPem: str,
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p>Cwtch: <label class="toxaddr">' + \
|
'<p>Cwtch: <label class="toxaddr">' + \
|
||||||
cwtchAddress + '</label></p>\n'
|
cwtchAddress + '</label></p>\n'
|
||||||
|
if EnigmaPubKey:
|
||||||
|
donateSection += \
|
||||||
|
'<p>Enigma: <label class="toxaddr">' + \
|
||||||
|
EnigmaPubKey + '</label></p>\n'
|
||||||
if PGPfingerprint:
|
if PGPfingerprint:
|
||||||
donateSection += \
|
donateSection += \
|
||||||
'<p class="pgp">PGP: ' + \
|
'<p class="pgp">PGP: ' + \
|
||||||
|
@ -1853,6 +1859,7 @@ def _htmlEditProfileContactInfo(nickname: str,
|
||||||
cwtchAddress: str,
|
cwtchAddress: str,
|
||||||
PGPfingerprint: str,
|
PGPfingerprint: str,
|
||||||
PGPpubKey: str,
|
PGPpubKey: str,
|
||||||
|
EnigmaPubKey: str,
|
||||||
translate: {}) -> str:
|
translate: {}) -> str:
|
||||||
"""Contact Information section of edit profile screen
|
"""Contact Information section of edit profile screen
|
||||||
"""
|
"""
|
||||||
|
@ -1869,6 +1876,10 @@ def _htmlEditProfileContactInfo(nickname: str,
|
||||||
editProfileForm += editTextField('Briar', 'briarAddress', briarAddress)
|
editProfileForm += editTextField('Briar', 'briarAddress', briarAddress)
|
||||||
editProfileForm += editTextField('Jami', 'jamiAddress', jamiAddress)
|
editProfileForm += editTextField('Jami', 'jamiAddress', jamiAddress)
|
||||||
editProfileForm += editTextField('Cwtch', 'cwtchAddress', cwtchAddress)
|
editProfileForm += editTextField('Cwtch', 'cwtchAddress', cwtchAddress)
|
||||||
|
enigmaUrl = 'https://github.com/enigma-reloaded/enigma-reloaded'
|
||||||
|
editProfileForm += \
|
||||||
|
editTextField('<a href="' + enigmaUrl + '">Enigma</a>',
|
||||||
|
'enigmapubkey', EnigmaPubKey)
|
||||||
editProfileForm += editTextField(translate['PGP Fingerprint'],
|
editProfileForm += editTextField(translate['PGP Fingerprint'],
|
||||||
'openpgp', PGPfingerprint)
|
'openpgp', PGPfingerprint)
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
|
@ -2079,7 +2090,8 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
notifyLikes = notifyReactions = ''
|
notifyLikes = notifyReactions = ''
|
||||||
hideLikeButton = hideReactionButton = mediaInstanceStr = ''
|
hideLikeButton = hideReactionButton = mediaInstanceStr = ''
|
||||||
blogsInstanceStr = newsInstanceStr = movedTo = twitterStr = ''
|
blogsInstanceStr = newsInstanceStr = movedTo = twitterStr = ''
|
||||||
bioStr = donateUrl = websiteUrl = emailAddress = PGPpubKey = ''
|
bioStr = donateUrl = websiteUrl = emailAddress = ''
|
||||||
|
PGPpubKey = EnigmaPubKey = ''
|
||||||
PGPfingerprint = xmppAddress = matrixAddress = ''
|
PGPfingerprint = xmppAddress = matrixAddress = ''
|
||||||
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
ssbAddress = blogAddress = toxAddress = jamiAddress = ''
|
||||||
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
cwtchAddress = briarAddress = manuallyApprovesFollowers = ''
|
||||||
|
@ -2099,6 +2111,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
jamiAddress = getJamiAddress(actorJson)
|
jamiAddress = getJamiAddress(actorJson)
|
||||||
cwtchAddress = getCwtchAddress(actorJson)
|
cwtchAddress = getCwtchAddress(actorJson)
|
||||||
emailAddress = getEmailAddress(actorJson)
|
emailAddress = getEmailAddress(actorJson)
|
||||||
|
EnigmaPubKey = getEnigmaPubKey(actorJson)
|
||||||
PGPpubKey = getPGPpubKey(actorJson)
|
PGPpubKey = getPGPpubKey(actorJson)
|
||||||
PGPfingerprint = getPGPfingerprint(actorJson)
|
PGPfingerprint = getPGPfingerprint(actorJson)
|
||||||
if actorJson.get('name'):
|
if actorJson.get('name'):
|
||||||
|
@ -2240,7 +2253,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
ssbAddress, toxAddress,
|
ssbAddress, toxAddress,
|
||||||
briarAddress, jamiAddress,
|
briarAddress, jamiAddress,
|
||||||
cwtchAddress, PGPfingerprint,
|
cwtchAddress, PGPfingerprint,
|
||||||
PGPpubKey, translate)
|
PGPpubKey, EnigmaPubKey, translate)
|
||||||
|
|
||||||
# Customize images and banners
|
# Customize images and banners
|
||||||
editProfileForm += _htmlEditProfileBackground(newsInstance, translate)
|
editProfileForm += _htmlEditProfileBackground(newsInstance, translate)
|
||||||
|
|
Loading…
Reference in New Issue