Prepare for alternative property names

main
Bob Mottram 2022-05-11 17:10:38 +01:00
parent ad1dad2144
commit 6033fca4d4
14 changed files with 300 additions and 90 deletions

View File

@ -14,9 +14,14 @@ def get_briar_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('briar'): if not name_value.lower().startswith('briar'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -71,11 +76,16 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('briar'): if not name_value.lower().startswith('briar'):
continue continue
property_found = property_value property_found = property_value
break break
@ -85,11 +95,16 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('briar'): if not name_value.lower().startswith('briar'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -16,9 +16,14 @@ def get_cwtch_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('cwtch'): if not name_value.lower().startswith('cwtch'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -59,11 +64,16 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('cwtch'): if not name_value.lower().startswith('cwtch'):
continue continue
property_found = property_value property_found = property_value
break break
@ -73,11 +83,16 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('cwtch'): if not name_value.lower().startswith('cwtch'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -25,9 +25,14 @@ def get_donation_url(actor_json: {}) -> str:
return '' return ''
donation_type = _get_donation_types() donation_type = _get_donation_types()
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if property_value['name'].lower() not in donation_type: if name_value.lower() not in donation_type:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -51,9 +56,14 @@ def get_website(actor_json: {}, translate: {}) -> str:
match_strings = _get_website_strings() match_strings = _get_website_strings()
match_strings.append(translate['Website'].lower()) match_strings.append(translate['Website'].lower())
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if property_value['name'].lower() not in match_strings: if name_value.lower() not in match_strings:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -92,11 +102,16 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower() != donate_name: if not name_value.lower() != donate_name:
continue continue
property_found = property_value property_found = property_value
break break
@ -111,11 +126,16 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
donate_url + '</a>' donate_url + '</a>'
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if property_value['name'].lower() != donate_name: if name_value.lower() != donate_name:
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -14,9 +14,14 @@ def get_enigma_pub_key(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('enigma'): if not name_value.lower().startswith('enigma'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -41,11 +46,16 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('enigma'): if not name_value.lower().startswith('enigma'):
continue continue
property_found = property_value property_found = property_value
break break
@ -55,11 +65,16 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('enigma'): if not name_value.lower().startswith('enigma'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -73,11 +73,16 @@ def set_actor_languages(base_dir: str, actor_json: {},
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('languages'): if not name_value.lower().startswith('languages'):
continue continue
property_found = property_value property_found = property_value
break break

View File

@ -14,9 +14,14 @@ def get_matrix_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('matrix'): if not name_value.lower().startswith('matrix'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -45,11 +50,16 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('matrix'): if not name_value.lower().startswith('matrix'):
continue continue
property_found = property_value property_found = property_value
break break
@ -70,11 +80,16 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('matrix'): if not name_value.lower().startswith('matrix'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -130,9 +130,14 @@ def _person_receive_update_outbox(recent_posts_cache: {},
# update fields within actor # update fields within actor
if 'attachment' in updated_actor_json: if 'attachment' in updated_actor_json:
for new_property_value in updated_actor_json['attachment']: for new_property_value in updated_actor_json['attachment']:
if not new_property_value.get('name'): name_value = None
if new_property_value.get('name'):
name_value = new_property_value['name']
elif new_property_value.get('schema:name'):
name_value = new_property_value['schema:name']
if not name_value:
continue continue
if new_property_value['name'] not in updatable_attachments: if name_value not in updatable_attachments:
continue continue
if not new_property_value.get('type'): if not new_property_value.get('type'):
continue continue
@ -147,8 +152,14 @@ def _person_receive_update_outbox(recent_posts_cache: {},
if actor_json['attachment'][attach_idx]['type'] != \ if actor_json['attachment'][attach_idx]['type'] != \
'PropertyValue': 'PropertyValue':
continue continue
if actor_json['attachment'][attach_idx]['name'] != \ attach_name = ''
new_property_value['name']: if actor_json['attachment'][attach_idx].get('name'):
attach_name = \
actor_json['attachment'][attach_idx]['name']
elif actor_json['attachment'][attach_idx].get('schema:name'):
attach_name = \
actor_json['attachment'][attach_idx]['schema:name']
if attach_name != name_value:
continue continue
if actor_json['attachment'][attach_idx]['value'] != \ if actor_json['attachment'][attach_idx]['value'] != \
new_property_value['value']: new_property_value['value']:
@ -159,7 +170,7 @@ def _person_receive_update_outbox(recent_posts_cache: {},
break break
if not found: if not found:
actor_json['attachment'].append({ actor_json['attachment'].append({
"name": new_property_value['name'], "name": name_value,
"type": "PropertyValue", "type": "PropertyValue",
"value": new_property_value['value'] "value": new_property_value['value']
}) })

81
pgp.py
View File

@ -36,9 +36,14 @@ def get_email_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('email'): if not name_value.lower().startswith('email'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -60,9 +65,14 @@ def get_pgp_pub_key(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('pgp'): if not name_value.lower().startswith('pgp'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -82,9 +92,14 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('openpgp'): if not name_value.lower().startswith('openpgp'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -117,11 +132,16 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('email'): if not name_value.lower().startswith('email'):
continue continue
property_found = property_value property_found = property_value
break break
@ -131,11 +151,16 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('email'): if not name_value.lower().startswith('email'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
@ -168,11 +193,16 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('pgp'): if not name_value.lower().startswith('pgp'):
continue continue
property_found = property_value property_found = property_value
break break
@ -182,11 +212,16 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('pgp'): if not name_value.lower().startswith('pgp'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue
@ -217,11 +252,16 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('openpgp'): if not name_value.lower().startswith('openpgp'):
continue continue
property_found = property_value property_found = property_value
break break
@ -231,11 +271,16 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('openpgp'): if not name_value.lower().startswith('openpgp'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

27
ssb.py
View File

@ -14,9 +14,14 @@ def get_ssb_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('ssb'): if not name_value.lower().startswith('ssb'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -62,11 +67,16 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('ssb'): if not name_value.lower().startswith('ssb'):
continue continue
property_found = property_value property_found = property_value
break break
@ -76,11 +86,16 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('ssb'): if not name_value.lower().startswith('ssb'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

27
tox.py
View File

@ -14,9 +14,14 @@ def get_tox_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('tox'): if not name_value.lower().startswith('tox'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -67,11 +72,16 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('tox'): if not name_value.lower().startswith('tox'):
continue continue
property_found = property_value property_found = property_value
break break
@ -81,11 +91,16 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith('tox'): if not name_value.lower().startswith('tox'):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -52,9 +52,14 @@ def get_actor_languages_list(actor_json: {}) -> []:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return [] return []
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith('languages'): if not name_value.lower().startswith('languages'):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -3113,9 +3118,14 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str:
return '' return ''
property_name = property_name.lower() property_name = property_name.lower()
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value['name'].lower().startswith(property_name): if not name_value.lower().startswith(property_name):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue

View File

@ -183,11 +183,16 @@ def _set_actor_property_url(actor_json: {},
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith(property_name_lower): if not name_value.lower().startswith(property_name_lower):
continue continue
property_found = property_value property_found = property_value
break break
@ -210,11 +215,16 @@ def _set_actor_property_url(actor_json: {},
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not property_value['name'].lower().startswith(property_name_lower): if not name_value.lower().startswith(property_name_lower):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue

View File

@ -414,9 +414,14 @@ def _webfinger_updateFromProfile(wf_json: {}, actor_json: {}) -> bool:
aliases_not_found.append(alias) aliases_not_found.append(alias)
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
property_name = property_value['name'].lower() property_name = name_value.lower()
found = False found = False
for name, alias in webfinger_property_name.items(): for name, alias in webfinger_property_name.items():
if name == property_name: if name == property_name:

36
xmpp.py
View File

@ -14,11 +14,15 @@ def get_xmpp_address(actor_json: {}) -> str:
if not actor_json.get('attachment'): if not actor_json.get('attachment'):
return '' return ''
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name'].lower()
elif property_value.get('schema:name'):
name_value = property_value['schema:name'].lower()
if not name_value:
continue continue
name_lower = property_value['name'].lower() if not (name_value.startswith('xmpp') or
if not (name_lower.startswith('xmpp') or name_value.startswith('jabber')):
name_lower.startswith('jabber')):
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
@ -53,12 +57,17 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
# remove any existing value # remove any existing value
property_found = None property_found = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if not (property_value['name'].lower().startswith('xmpp') or if not (name_value.lower().startswith('xmpp') or
property_value['name'].lower().startswith('jabber')): name_value.lower().startswith('jabber')):
continue continue
property_found = property_value property_found = property_value
break break
@ -68,13 +77,18 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None:
return return
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not property_value.get('name'): name_value = None
if property_value.get('name'):
name_value = property_value['name']
elif property_value.get('schema:name'):
name_value = property_value['schema:name']
if not name_value:
continue continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
name_lower = property_value['name'].lower() name_value = name_value.lower()
if not (name_lower.startswith('xmpp') or if not (name_value.startswith('xmpp') or
name_lower.startswith('jabber')): name_value.startswith('jabber')):
continue continue
if property_value['type'] != 'PropertyValue': if property_value['type'] != 'PropertyValue':
continue continue