diff --git a/briar.py b/briar.py index 006f2cc9b..01a64e2f5 100644 --- a/briar.py +++ b/briar.py @@ -14,9 +14,14 @@ def get_briar_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('briar'): + if not name_value.lower().startswith('briar'): continue if not property_value.get('type'): continue @@ -71,11 +76,16 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('briar'): + if not name_value.lower().startswith('briar'): continue property_found = property_value break @@ -85,11 +95,16 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('briar'): + if not name_value.lower().startswith('briar'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/cwtch.py b/cwtch.py index 9f531e6f7..85eef02c8 100644 --- a/cwtch.py +++ b/cwtch.py @@ -16,9 +16,14 @@ def get_cwtch_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('cwtch'): + if not name_value.lower().startswith('cwtch'): continue if not property_value.get('type'): continue @@ -59,11 +64,16 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('cwtch'): + if not name_value.lower().startswith('cwtch'): continue property_found = property_value break @@ -73,11 +83,16 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('cwtch'): + if not name_value.lower().startswith('cwtch'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/donate.py b/donate.py index 7ec71e4b6..c013b7ea4 100644 --- a/donate.py +++ b/donate.py @@ -25,9 +25,14 @@ def get_donation_url(actor_json: {}) -> str: return '' donation_type = _get_donation_types() 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 - if property_value['name'].lower() not in donation_type: + if name_value.lower() not in donation_type: continue if not property_value.get('type'): continue @@ -51,9 +56,14 @@ def get_website(actor_json: {}, translate: {}) -> str: match_strings = _get_website_strings() match_strings.append(translate['Website'].lower()) 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 - if property_value['name'].lower() not in match_strings: + if name_value.lower() not in match_strings: continue if not property_value.get('type'): continue @@ -92,11 +102,16 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower() != donate_name: + if not name_value.lower() != donate_name: continue property_found = property_value break @@ -111,11 +126,16 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None: donate_url + '' 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 if not property_value.get('type'): continue - if property_value['name'].lower() != donate_name: + if name_value.lower() != donate_name: continue if property_value['type'] != 'PropertyValue': continue diff --git a/enigma.py b/enigma.py index 99820529d..1cdcd7fc5 100644 --- a/enigma.py +++ b/enigma.py @@ -14,9 +14,14 @@ def get_enigma_pub_key(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('enigma'): + if not name_value.lower().startswith('enigma'): continue if not property_value.get('type'): continue @@ -41,11 +46,16 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('enigma'): + if not name_value.lower().startswith('enigma'): continue property_found = property_value break @@ -55,11 +65,16 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('enigma'): + if not name_value.lower().startswith('enigma'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/languages.py b/languages.py index 2a2ed4869..16f59742c 100644 --- a/languages.py +++ b/languages.py @@ -73,11 +73,16 @@ def set_actor_languages(base_dir: str, actor_json: {}, # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('languages'): + if not name_value.lower().startswith('languages'): continue property_found = property_value break diff --git a/matrix.py b/matrix.py index 1fcd7b801..94d0fdb28 100644 --- a/matrix.py +++ b/matrix.py @@ -14,9 +14,14 @@ def get_matrix_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('matrix'): + if not name_value.lower().startswith('matrix'): continue if not property_value.get('type'): continue @@ -45,11 +50,16 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('matrix'): + if not name_value.lower().startswith('matrix'): continue property_found = property_value break @@ -70,11 +80,16 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('matrix'): + if not name_value.lower().startswith('matrix'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/outbox.py b/outbox.py index 055d01933..f6074e9c5 100644 --- a/outbox.py +++ b/outbox.py @@ -130,9 +130,14 @@ def _person_receive_update_outbox(recent_posts_cache: {}, # update fields within actor if 'attachment' in updated_actor_json: 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 - if new_property_value['name'] not in updatable_attachments: + if name_value not in updatable_attachments: continue if not new_property_value.get('type'): continue @@ -147,8 +152,14 @@ def _person_receive_update_outbox(recent_posts_cache: {}, if actor_json['attachment'][attach_idx]['type'] != \ 'PropertyValue': continue - if actor_json['attachment'][attach_idx]['name'] != \ - new_property_value['name']: + attach_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 if actor_json['attachment'][attach_idx]['value'] != \ new_property_value['value']: @@ -159,7 +170,7 @@ def _person_receive_update_outbox(recent_posts_cache: {}, break if not found: actor_json['attachment'].append({ - "name": new_property_value['name'], + "name": name_value, "type": "PropertyValue", "value": new_property_value['value'] }) diff --git a/pgp.py b/pgp.py index 687baea71..1d4c8f734 100644 --- a/pgp.py +++ b/pgp.py @@ -36,9 +36,14 @@ def get_email_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('email'): + if not name_value.lower().startswith('email'): continue if not property_value.get('type'): continue @@ -60,9 +65,14 @@ def get_pgp_pub_key(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('pgp'): + if not name_value.lower().startswith('pgp'): continue if not property_value.get('type'): continue @@ -82,9 +92,14 @@ def get_pgp_fingerprint(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('openpgp'): + if not name_value.lower().startswith('openpgp'): continue if not property_value.get('type'): continue @@ -117,11 +132,16 @@ def set_email_address(actor_json: {}, email_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('email'): + if not name_value.lower().startswith('email'): continue property_found = property_value break @@ -131,11 +151,16 @@ def set_email_address(actor_json: {}, email_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('email'): + if not name_value.lower().startswith('email'): continue if property_value['type'] != 'PropertyValue': continue @@ -168,11 +193,16 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('pgp'): + if not name_value.lower().startswith('pgp'): continue property_found = property_value break @@ -182,11 +212,16 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('pgp'): + if not name_value.lower().startswith('pgp'): continue if property_value['type'] != 'PropertyValue': continue @@ -217,11 +252,16 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('openpgp'): + if not name_value.lower().startswith('openpgp'): continue property_found = property_value break @@ -231,11 +271,16 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('openpgp'): + if not name_value.lower().startswith('openpgp'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/ssb.py b/ssb.py index be7bec425..0b015095e 100644 --- a/ssb.py +++ b/ssb.py @@ -14,9 +14,14 @@ def get_ssb_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('ssb'): + if not name_value.lower().startswith('ssb'): continue if not property_value.get('type'): continue @@ -62,11 +67,16 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('ssb'): + if not name_value.lower().startswith('ssb'): continue property_found = property_value break @@ -76,11 +86,16 @@ def set_ssb_address(actor_json: {}, ssb_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('ssb'): + if not name_value.lower().startswith('ssb'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/tox.py b/tox.py index c1e940043..ad3f84ffb 100644 --- a/tox.py +++ b/tox.py @@ -14,9 +14,14 @@ def get_tox_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - if not property_value['name'].lower().startswith('tox'): + if not name_value.lower().startswith('tox'): continue if not property_value.get('type'): continue @@ -67,11 +72,16 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('tox'): + if not name_value.lower().startswith('tox'): continue property_found = property_value break @@ -81,11 +91,16 @@ def set_tox_address(actor_json: {}, tox_address: str) -> None: return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith('tox'): + if not name_value.lower().startswith('tox'): continue if property_value['type'] != 'PropertyValue': continue diff --git a/utils.py b/utils.py index 1b647e116..93acbd98b 100644 --- a/utils.py +++ b/utils.py @@ -52,9 +52,14 @@ def get_actor_languages_list(actor_json: {}) -> []: if not actor_json.get('attachment'): return [] 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 - if not property_value['name'].lower().startswith('languages'): + if not name_value.lower().startswith('languages'): continue if not property_value.get('type'): continue @@ -3113,9 +3118,14 @@ def get_actor_property_url(actor_json: {}, property_name: str) -> str: return '' property_name = property_name.lower() 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 - if not property_value['name'].lower().startswith(property_name): + if not name_value.lower().startswith(property_name): continue if not property_value.get('type'): continue diff --git a/webapp_utils.py b/webapp_utils.py index aaf7863c4..94002da9b 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -183,11 +183,16 @@ def _set_actor_property_url(actor_json: {}, # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith(property_name_lower): + if not name_value.lower().startswith(property_name_lower): continue property_found = property_value break @@ -210,11 +215,16 @@ def _set_actor_property_url(actor_json: {}, return 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 if not property_value.get('type'): continue - if not property_value['name'].lower().startswith(property_name_lower): + if not name_value.lower().startswith(property_name_lower): continue if property_value['type'] != 'PropertyValue': continue diff --git a/webfinger.py b/webfinger.py index c7735ed2c..a674f7310 100644 --- a/webfinger.py +++ b/webfinger.py @@ -414,9 +414,14 @@ def _webfinger_updateFromProfile(wf_json: {}, actor_json: {}) -> bool: aliases_not_found.append(alias) 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 - property_name = property_value['name'].lower() + property_name = name_value.lower() found = False for name, alias in webfinger_property_name.items(): if name == property_name: diff --git a/xmpp.py b/xmpp.py index 17c672ff1..daa16c5e5 100644 --- a/xmpp.py +++ b/xmpp.py @@ -14,11 +14,15 @@ def get_xmpp_address(actor_json: {}) -> str: if not actor_json.get('attachment'): return '' 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 - name_lower = property_value['name'].lower() - if not (name_lower.startswith('xmpp') or - name_lower.startswith('jabber')): + if not (name_value.startswith('xmpp') or + name_value.startswith('jabber')): continue if not property_value.get('type'): continue @@ -53,12 +57,17 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None: # remove any existing value property_found = None 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 if not property_value.get('type'): continue - if not (property_value['name'].lower().startswith('xmpp') or - property_value['name'].lower().startswith('jabber')): + if not (name_value.lower().startswith('xmpp') or + name_value.lower().startswith('jabber')): continue property_found = property_value break @@ -68,13 +77,18 @@ def set_xmpp_address(actor_json: {}, xmpp_address: str) -> None: return 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 if not property_value.get('type'): continue - name_lower = property_value['name'].lower() - if not (name_lower.startswith('xmpp') or - name_lower.startswith('jabber')): + name_value = name_value.lower() + if not (name_value.startswith('xmpp') or + name_value.startswith('jabber')): continue if property_value['type'] != 'PropertyValue': continue