Snake case for profile contact variables

main
Bob Mottram 2021-12-31 18:11:17 +00:00
parent 81c3fc8789
commit 63334f8250
10 changed files with 173 additions and 172 deletions

View File

@ -5397,38 +5397,38 @@ class PubServer(BaseHTTPRequestHandler):
actorChanged = True
# change Enigma public key
currentEnigmaPubKey = get_enigma_pub_key(actor_json)
currentenigma_pub_key = get_enigma_pub_key(actor_json)
if fields.get('enigmapubkey'):
if fields['enigmapubkey'] != currentEnigmaPubKey:
if fields['enigmapubkey'] != currentenigma_pub_key:
set_enigma_pub_key(actor_json,
fields['enigmapubkey'])
actorChanged = True
else:
if currentEnigmaPubKey:
if currentenigma_pub_key:
set_enigma_pub_key(actor_json, '')
actorChanged = True
# change PGP public key
currentPGPpubKey = get_pgp_pub_key(actor_json)
currentpgp_pub_key = get_pgp_pub_key(actor_json)
if fields.get('pgp'):
if fields['pgp'] != currentPGPpubKey:
if fields['pgp'] != currentpgp_pub_key:
set_pgp_pub_key(actor_json,
fields['pgp'])
actorChanged = True
else:
if currentPGPpubKey:
if currentpgp_pub_key:
set_pgp_pub_key(actor_json, '')
actorChanged = True
# change PGP fingerprint
currentPGPfingerprint = get_pgp_fingerprint(actor_json)
currentpgp_fingerprint = get_pgp_fingerprint(actor_json)
if fields.get('openpgp'):
if fields['openpgp'] != currentPGPfingerprint:
if fields['openpgp'] != currentpgp_fingerprint:
set_pgp_fingerprint(actor_json,
fields['openpgp'])
actorChanged = True
else:
if currentPGPfingerprint:
if currentpgp_fingerprint:
set_pgp_fingerprint(actor_json, '')
actorChanged = True
@ -7097,20 +7097,20 @@ class PubServer(BaseHTTPRequestHandler):
if len(optionsList) > 3:
optionsLink = optionsList[3]
isGroup = False
donateUrl = None
websiteUrl = None
EnigmaPubKey = None
PGPpubKey = None
PGPfingerprint = None
xmppAddress = None
matrixAddress = None
blogAddress = None
toxAddress = None
briarAddress = None
jamiAddress = None
donate_url = None
website_url = None
enigma_pub_key = None
pgp_pub_key = None
pgp_fingerprint = None
xmpp_address = None
matrix_address = None
blog_address = None
tox_address = None
briar_address = None
jami_address = None
cwtch_address = None
ssbAddress = None
emailAddress = None
ssb_address = None
email_address = None
lockedAccount = False
alsoKnownAs = None
movedTo = ''
@ -7127,20 +7127,20 @@ class PubServer(BaseHTTPRequestHandler):
if actor_json['type'] == 'Group':
isGroup = True
lockedAccount = get_locked_account(actor_json)
donateUrl = get_donation_url(actor_json)
websiteUrl = get_website(actor_json, self.server.translate)
xmppAddress = get_xmpp_address(actor_json)
matrixAddress = get_matrix_address(actor_json)
ssbAddress = get_ssb_address(actor_json)
blogAddress = get_blog_address(actor_json)
toxAddress = get_tox_address(actor_json)
briarAddress = get_briar_address(actor_json)
jamiAddress = get_jami_address(actor_json)
donate_url = get_donation_url(actor_json)
website_url = get_website(actor_json, self.server.translate)
xmpp_address = get_xmpp_address(actor_json)
matrix_address = get_matrix_address(actor_json)
ssb_address = get_ssb_address(actor_json)
blog_address = get_blog_address(actor_json)
tox_address = get_tox_address(actor_json)
briar_address = get_briar_address(actor_json)
jami_address = get_jami_address(actor_json)
cwtch_address = get_cwtch_address(actor_json)
emailAddress = get_email_address(actor_json)
EnigmaPubKey = get_enigma_pub_key(actor_json)
PGPpubKey = get_pgp_pub_key(actor_json)
PGPfingerprint = get_pgp_fingerprint(actor_json)
email_address = get_email_address(actor_json)
enigma_pub_key = get_enigma_pub_key(actor_json)
pgp_pub_key = get_pgp_pub_key(actor_json)
pgp_fingerprint = get_pgp_fingerprint(actor_json)
if actor_json.get('alsoKnownAs'):
alsoKnownAs = actor_json['alsoKnownAs']
@ -7169,14 +7169,14 @@ class PubServer(BaseHTTPRequestHandler):
optionsActor,
optionsProfileUrl,
optionsLink,
pageNumber, donateUrl, websiteUrl,
xmppAddress, matrixAddress,
ssbAddress, blogAddress,
toxAddress, briarAddress,
jamiAddress, cwtch_address,
EnigmaPubKey,
PGPpubKey, PGPfingerprint,
emailAddress,
pageNumber, donate_url, website_url,
xmpp_address, matrix_address,
ssb_address, blog_address,
tox_address, briar_address,
jami_address, cwtch_address,
enigma_pub_key,
pgp_pub_key, pgp_fingerprint,
email_address,
self.server.dormant_months,
backToPath,
lockedAccount,

View File

@ -37,9 +37,9 @@ def get_donation_url(actor_json: {}) -> str:
continue
if '<a href="' not in property_value['value']:
continue
donateUrl = property_value['value'].split('<a href="')[1]
if '"' in donateUrl:
return donateUrl.split('"')[0]
donate_url = property_value['value'].split('<a href="')[1]
if '"' in donate_url:
return donate_url.split('"')[0]
return ''
@ -65,17 +65,17 @@ def get_website(actor_json: {}, translate: {}) -> str:
return ''
def set_donation_url(actor_json: {}, donateUrl: str) -> None:
def set_donation_url(actor_json: {}, donate_url: str) -> None:
"""Sets a link used for donations
"""
notUrl = False
if '.' not in donateUrl:
if '.' not in donate_url:
notUrl = True
if '://' not in donateUrl:
if '://' not in donate_url:
notUrl = True
if ' ' in donateUrl:
if ' ' in donate_url:
notUrl = True
if '<' in donateUrl:
if '<' in donate_url:
notUrl = True
if not actor_json.get('attachment'):
@ -84,7 +84,7 @@ def set_donation_url(actor_json: {}, donateUrl: str) -> None:
donationType = _get_donation_types()
donateName = None
for paymentService in donationType:
if paymentService in donateUrl:
if paymentService in donate_url:
donateName = paymentService
if not donateName:
return
@ -106,9 +106,9 @@ def set_donation_url(actor_json: {}, donateUrl: str) -> None:
return
donateValue = \
'<a href="' + donateUrl + \
'<a href="' + donate_url + \
'" rel="me nofollow noopener noreferrer" target="_blank">' + \
donateUrl + '</a>'
donate_url + '</a>'
for property_value in actor_json['attachment']:
if not property_value.get('name'):
@ -130,18 +130,18 @@ def set_donation_url(actor_json: {}, donateUrl: str) -> None:
actor_json['attachment'].append(newDonate)
def set_website(actor_json: {}, websiteUrl: str, translate: {}) -> None:
def set_website(actor_json: {}, website_url: str, translate: {}) -> None:
"""Sets a web address
"""
websiteUrl = websiteUrl.strip()
website_url = website_url.strip()
notUrl = False
if '.' not in websiteUrl:
if '.' not in website_url:
notUrl = True
if '://' not in websiteUrl:
if '://' not in website_url:
notUrl = True
if ' ' in websiteUrl:
if ' ' in website_url:
notUrl = True
if '<' in websiteUrl:
if '<' in website_url:
notUrl = True
if not actor_json.get('attachment'):
@ -169,6 +169,6 @@ def set_website(actor_json: {}, websiteUrl: str, translate: {}) -> None:
newEntry = {
"name": 'Website',
"type": "PropertyValue",
"value": websiteUrl
"value": website_url
}
actor_json['attachment'].append(newEntry)

18
jami.py
View File

@ -39,22 +39,22 @@ def get_jami_address(actor_json: {}) -> str:
return ''
def set_jami_address(actor_json: {}, jamiAddress: str) -> None:
def set_jami_address(actor_json: {}, jami_address: str) -> None:
"""Sets an jami address for the given actor
"""
notJamiAddress = False
if len(jamiAddress) < 2:
if len(jami_address) < 2:
notJamiAddress = True
if '"' in jamiAddress:
if '"' in jami_address:
notJamiAddress = True
if ' ' in jamiAddress:
if ' ' in jami_address:
notJamiAddress = True
if '.' in jamiAddress:
if '.' in jami_address:
notJamiAddress = True
if ',' in jamiAddress:
if ',' in jami_address:
notJamiAddress = True
if '<' in jamiAddress:
if '<' in jami_address:
notJamiAddress = True
if not actor_json.get('attachment'):
@ -85,12 +85,12 @@ def set_jami_address(actor_json: {}, jamiAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = jamiAddress
property_value['value'] = jami_address
return
newJamiAddress = {
"name": "Jami",
"type": "PropertyValue",
"value": jamiAddress
"value": jami_address
}
actor_json['attachment'].append(newJamiAddress)

View File

@ -36,7 +36,7 @@ def get_matrix_address(actor_json: {}) -> str:
return ''
def set_matrix_address(actor_json: {}, matrixAddress: str) -> None:
def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
"""Sets an matrix address for the given actor
"""
if not actor_json.get('attachment'):
@ -56,17 +56,17 @@ def set_matrix_address(actor_json: {}, matrixAddress: str) -> None:
if propertyFound:
actor_json['attachment'].remove(propertyFound)
if '@' not in matrixAddress:
if '@' not in matrix_address:
return
if not matrixAddress.startswith('@'):
if not matrix_address.startswith('@'):
return
if '.' not in matrixAddress:
if '.' not in matrix_address:
return
if '"' in matrixAddress:
if '"' in matrix_address:
return
if '<' in matrixAddress:
if '<' in matrix_address:
return
if ':' not in matrixAddress:
if ':' not in matrix_address:
return
for property_value in actor_json['attachment']:
@ -78,12 +78,12 @@ def set_matrix_address(actor_json: {}, matrixAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = matrixAddress
property_value['value'] = matrix_address
return
newMatrixAddress = {
"name": "Matrix",
"type": "PropertyValue",
"value": matrixAddress
"value": matrix_address
}
actor_json['attachment'].append(newMatrixAddress)

50
pgp.py
View File

@ -91,17 +91,17 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
return ''
def set_email_address(actor_json: {}, emailAddress: str) -> None:
def set_email_address(actor_json: {}, email_address: str) -> None:
"""Sets the email address for the given actor
"""
notEmailAddress = False
if '@' not in emailAddress:
if '@' not in email_address:
notEmailAddress = True
if '.' not in emailAddress:
if '.' not in email_address:
notEmailAddress = True
if '<' in emailAddress:
if '<' in email_address:
notEmailAddress = True
if emailAddress.startswith('@'):
if email_address.startswith('@'):
notEmailAddress = True
if not actor_json.get('attachment'):
@ -132,27 +132,27 @@ def set_email_address(actor_json: {}, emailAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = emailAddress
property_value['value'] = email_address
return
newEmailAddress = {
"name": "Email",
"type": "PropertyValue",
"value": emailAddress
"value": email_address
}
actor_json['attachment'].append(newEmailAddress)
def set_pgp_pub_key(actor_json: {}, PGPpubKey: str) -> None:
def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
"""Sets a PGP public key for the given actor
"""
removeKey = False
if not PGPpubKey:
if not pgp_pub_key:
removeKey = True
else:
if not contains_pgp_public_key(PGPpubKey):
if not contains_pgp_public_key(pgp_pub_key):
removeKey = True
if '<' in PGPpubKey:
if '<' in pgp_pub_key:
removeKey = True
if not actor_json.get('attachment'):
@ -183,15 +183,15 @@ def set_pgp_pub_key(actor_json: {}, PGPpubKey: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = PGPpubKey
property_value['value'] = pgp_pub_key
return
newPGPpubKey = {
newpgp_pub_key = {
"name": "PGP",
"type": "PropertyValue",
"value": PGPpubKey
"value": pgp_pub_key
}
actor_json['attachment'].append(newPGPpubKey)
actor_json['attachment'].append(newpgp_pub_key)
def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
@ -235,12 +235,12 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
property_value['value'] = fingerprint.strip()
return
newPGPfingerprint = {
newpgp_fingerprint = {
"name": "OpenPGP",
"type": "PropertyValue",
"value": fingerprint
}
actor_json['attachment'].append(newPGPfingerprint)
actor_json['attachment'].append(newpgp_fingerprint)
def extract_pgp_public_key(content: str) -> str:
@ -470,15 +470,15 @@ def pgp_public_key_upload(base_dir: str, session,
if not test:
if debug:
print('Getting PGP public key')
PGPpubKey = pgp_local_public_key()
if not PGPpubKey:
pgp_pub_key = pgp_local_public_key()
if not pgp_pub_key:
return None
PGPpubKeyId = _pgp_local_public_key_id()
pgp_pub_keyId = _pgp_local_public_key_id()
else:
if debug:
print('Testing with PGP public key ' + test)
PGPpubKey = test
PGPpubKeyId = None
pgp_pub_key = test
pgp_pub_keyId = None
domain_full = get_full_domain(domain, port)
if debug:
@ -531,15 +531,15 @@ def pgp_public_key_upload(base_dir: str, session,
return None
# set the pgp details
if PGPpubKeyId:
set_pgp_fingerprint(actor_json, PGPpubKeyId)
if pgp_pub_keyId:
set_pgp_fingerprint(actor_json, pgp_pub_keyId)
else:
if debug:
print('No PGP key Id. Continuing anyway.')
if debug:
print('Setting PGP key within ' + actor)
set_pgp_pub_key(actor_json, PGPpubKey)
set_pgp_pub_key(actor_json, pgp_pub_key)
# create an actor update
statusNumber, published = get_status_number()

18
ssb.py
View File

@ -39,21 +39,21 @@ def get_ssb_address(actor_json: {}) -> str:
return ''
def set_ssb_address(actor_json: {}, ssbAddress: str) -> None:
def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
"""Sets an ssb address for the given actor
"""
notSSBAddress = False
if not ssbAddress.startswith('@'):
if not ssb_address.startswith('@'):
notSSBAddress = True
if '=.' not in ssbAddress:
if '=.' not in ssb_address:
notSSBAddress = True
if '"' in ssbAddress:
if '"' in ssb_address:
notSSBAddress = True
if ' ' in ssbAddress:
if ' ' in ssb_address:
notSSBAddress = True
if ',' in ssbAddress:
if ',' in ssb_address:
notSSBAddress = True
if '<' in ssbAddress:
if '<' in ssb_address:
notSSBAddress = True
if not actor_json.get('attachment'):
@ -84,12 +84,12 @@ def set_ssb_address(actor_json: {}, ssbAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = ssbAddress
property_value['value'] = ssb_address
return
newSSBAddress = {
"name": "SSB",
"type": "PropertyValue",
"value": ssbAddress
"value": ssb_address
}
actor_json['attachment'].append(newSSBAddress)

20
tox.py
View File

@ -41,24 +41,24 @@ def get_tox_address(actor_json: {}) -> str:
return ''
def set_tox_address(actor_json: {}, toxAddress: str) -> None:
def set_tox_address(actor_json: {}, tox_address: str) -> None:
"""Sets an tox address for the given actor
"""
notToxAddress = False
if len(toxAddress) != 76:
if len(tox_address) != 76:
notToxAddress = True
if toxAddress.upper() != toxAddress:
if tox_address.upper() != tox_address:
notToxAddress = True
if '"' in toxAddress:
if '"' in tox_address:
notToxAddress = True
if ' ' in toxAddress:
if ' ' in tox_address:
notToxAddress = True
if '.' in toxAddress:
if '.' in tox_address:
notToxAddress = True
if ',' in toxAddress:
if ',' in tox_address:
notToxAddress = True
if '<' in toxAddress:
if '<' in tox_address:
notToxAddress = True
if not actor_json.get('attachment'):
@ -89,12 +89,12 @@ def set_tox_address(actor_json: {}, toxAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = toxAddress
property_value['value'] = tox_address
return
newToxAddress = {
"name": "Tox",
"type": "PropertyValue",
"value": toxAddress
"value": tox_address
}
actor_json['attachment'].append(newToxAddress)

View File

@ -39,20 +39,20 @@ def html_person_options(defaultTimeline: str,
optionsProfileUrl: str,
optionsLink: str,
pageNumber: int,
donateUrl: str,
donate_url: str,
webAddress: str,
xmppAddress: str,
matrixAddress: str,
ssbAddress: str,
blogAddress: str,
toxAddress: str,
briarAddress: str,
jamiAddress: str,
xmpp_address: str,
matrix_address: str,
ssb_address: str,
blog_address: str,
tox_address: str,
briar_address: str,
jami_address: str,
cwtch_address: str,
EnigmaPubKey: str,
PGPpubKey: str,
PGPfingerprint: str,
emailAddress: str,
enigma_pub_key: str,
pgp_pub_key: str,
pgp_fingerprint: str,
email_address: str,
dormant_months: int,
backToPath: str,
lockedAccount: bool,
@ -122,9 +122,9 @@ def html_person_options(defaultTimeline: str,
snoozeButtonStr = 'Unsnooze'
donateStr = ''
if donateUrl:
if donate_url:
donateStr = \
' <a href="' + donateUrl + \
' <a href="' + donate_url + \
' tabindex="-1""><button class="button" name="submitDonate">' + \
translate['Donate'] + '</button></a>\n'
@ -188,55 +188,56 @@ def html_person_options(defaultTimeline: str,
otherAccountsHtml += '</p>\n'
if ctr > 0:
optionsStr += otherAccountsHtml
if emailAddress:
if email_address:
optionsStr += \
'<p class="imText">' + translate['Email'] + \
': <a href="mailto:' + \
emailAddress + '">' + remove_html(emailAddress) + '</a></p>\n'
if xmppAddress:
email_address + '">' + remove_html(email_address) + '</a></p>\n'
if xmpp_address:
optionsStr += \
'<p class="imText">' + translate['XMPP'] + \
': <a href="xmpp:' + remove_html(xmppAddress) + '">' + \
xmppAddress + '</a></p>\n'
if matrixAddress:
': <a href="xmpp:' + remove_html(xmpp_address) + '">' + \
xmpp_address + '</a></p>\n'
if matrix_address:
optionsStr += \
'<p class="imText">' + translate['Matrix'] + ': ' + \
remove_html(matrixAddress) + '</p>\n'
if ssbAddress:
remove_html(matrix_address) + '</p>\n'
if ssb_address:
optionsStr += \
'<p class="imText">SSB: ' + remove_html(ssbAddress) + '</p>\n'
if blogAddress:
'<p class="imText">SSB: ' + remove_html(ssb_address) + '</p>\n'
if blog_address:
optionsStr += \
'<p class="imText">Blog: <a href="' + \
remove_html(blogAddress) + '">' + \
remove_html(blogAddress) + '</a></p>\n'
if toxAddress:
remove_html(blog_address) + '">' + \
remove_html(blog_address) + '</a></p>\n'
if tox_address:
optionsStr += \
'<p class="imText">Tox: ' + remove_html(toxAddress) + '</p>\n'
if briarAddress:
if briarAddress.startswith('briar://'):
'<p class="imText">Tox: ' + remove_html(tox_address) + '</p>\n'
if briar_address:
if briar_address.startswith('briar://'):
optionsStr += \
'<p class="imText">' + \
remove_html(briarAddress) + '</p>\n'
remove_html(briar_address) + '</p>\n'
else:
optionsStr += \
'<p class="imText">briar://' + \
remove_html(briarAddress) + '</p>\n'
if jamiAddress:
remove_html(briar_address) + '</p>\n'
if jami_address:
optionsStr += \
'<p class="imText">Jami: ' + remove_html(jamiAddress) + '</p>\n'
'<p class="imText">Jami: ' + remove_html(jami_address) + '</p>\n'
if cwtch_address:
optionsStr += \
'<p class="imText">Cwtch: ' + remove_html(cwtch_address) + '</p>\n'
if EnigmaPubKey:
if enigma_pub_key:
optionsStr += \
'<p class="imText">Enigma: ' + remove_html(EnigmaPubKey) + '</p>\n'
if PGPfingerprint:
'<p class="imText">Enigma: ' + \
remove_html(enigma_pub_key) + '</p>\n'
if pgp_fingerprint:
optionsStr += '<p class="pgp">PGP: ' + \
remove_html(PGPfingerprint).replace('\n', '<br>') + '</p>\n'
if PGPpubKey:
remove_html(pgp_fingerprint).replace('\n', '<br>') + '</p>\n'
if pgp_pub_key:
optionsStr += '<p class="pgp">' + \
remove_html(PGPpubKey).replace('\n', '<br>') + '</p>\n'
remove_html(pgp_pub_key).replace('\n', '<br>') + '</p>\n'
optionsStr += ' <form method="POST" action="' + \
originPathStr + '/personoptions">\n'
optionsStr += ' <input type="hidden" name="pageNumber" value="' + \

View File

@ -229,10 +229,10 @@ def _set_actor_property_url(actor_json: {},
actor_json['attachment'].append(newAddress)
def set_blog_address(actor_json: {}, blogAddress: str) -> None:
def set_blog_address(actor_json: {}, blog_address: str) -> None:
"""Sets an blog address for the given actor
"""
_set_actor_property_url(actor_json, 'Blog', remove_html(blogAddress))
_set_actor_property_url(actor_json, 'Blog', remove_html(blog_address))
def update_avatar_image_cache(signing_priv_key_pem: str,

14
xmpp.py
View File

@ -34,17 +34,17 @@ def get_xmpp_address(actor_json: {}) -> str:
return ''
def set_xmpp_address(actor_json: {}, xmppAddress: str) -> None:
def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
"""Sets an xmpp address for the given actor
"""
notXmppAddress = False
if '@' not in xmppAddress:
if '@' not in xmpp_address:
notXmppAddress = True
if '.' not in xmppAddress:
if '.' not in xmpp_address:
notXmppAddress = True
if '"' in xmppAddress:
if '"' in xmpp_address:
notXmppAddress = True
if '<' in xmppAddress:
if '<' in xmpp_address:
notXmppAddress = True
if not actor_json.get('attachment'):
@ -78,12 +78,12 @@ def set_xmpp_address(actor_json: {}, xmppAddress: str) -> None:
continue
if property_value['type'] != 'PropertyValue':
continue
property_value['value'] = xmppAddress
property_value['value'] = xmpp_address
return
newXmppAddress = {
"name": "XMPP",
"type": "PropertyValue",
"value": xmppAddress
"value": xmpp_address
}
actor_json['attachment'].append(newXmppAddress)