Check property types

main
bashrc 2026-05-05 13:36:14 +01:00
parent 3d7cf796be
commit 258562f8aa
13 changed files with 216 additions and 131 deletions

View File

@ -23,10 +23,12 @@ def get_briar_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -86,12 +88,12 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
actor_json['attachment']: list[dict] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found: dict = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
@ -115,8 +117,10 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -23,10 +23,12 @@ def get_cwtch_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -77,10 +79,12 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -101,8 +105,10 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -26,10 +26,12 @@ def get_discord(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -43,7 +45,7 @@ def get_discord(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
discord_text = property_value[prop_value_name] discord_text: str = property_value[prop_value_name]
return remove_html(discord_text) return remove_html(discord_text)
return '' return ''
@ -55,15 +57,17 @@ def set_discord(actor_json: {}, discord: str) -> None:
actor_json['attachment']: list[dict] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found: dict = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -81,10 +85,12 @@ def set_discord(actor_json: {}, discord: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -36,14 +36,16 @@ def get_donation_url(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
name_value_lower = name_value.lower() name_value_lower: str = name_value.lower()
found: bool = False found: bool = False
for donation_type_str in donation_type_list: for donation_type_str in donation_type_list:
if donation_type_str in name_value_lower: if donation_type_str in name_value_lower:
@ -64,13 +66,14 @@ def get_donation_url(actor_json: {}) -> str:
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
if '<a href="' in property_value[prop_value_name]: if '<a href="' in property_value[prop_value_name]:
donate_url = property_value[prop_value_name].split('<a href="')[1] donate_url: str = \
property_value[prop_value_name].split('<a href="')[1]
if '"' in donate_url: if '"' in donate_url:
donate_url = donate_url.split('"')[0] donate_url = donate_url.split('"')[0]
donate_url = remove_html(donate_url) donate_url = remove_html(donate_url)
return remove_link_tracking(donate_url) return remove_link_tracking(donate_url)
else: else:
donate_url = remove_html(property_value[prop_value_name]) donate_url: str = remove_html(property_value[prop_value_name])
if ' ' in donate_url: if ' ' in donate_url:
donate_url = donate_url.split(' ')[0] donate_url = donate_url.split(' ')[0]
if '://' in donate_url: if '://' in donate_url:
@ -108,10 +111,12 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -135,10 +140,12 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -23,10 +23,12 @@ def get_enigma_pub_key(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -60,10 +62,12 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -84,8 +88,10 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

6
git.py
View File

@ -240,10 +240,12 @@ def get_repo_url(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -268,7 +270,7 @@ def get_repo_url(actor_json: {}) -> str:
repo_url = remove_html(repo_url) repo_url = remove_html(repo_url)
return remove_link_tracking(repo_url) return remove_link_tracking(repo_url)
repo_sites = ('github.com', 'gitlab.com', 'codeberg.org') repo_sites: list[str] = ('github.com', 'gitlab.com', 'codeberg.org')
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):

14
lxmf.py
View File

@ -70,10 +70,12 @@ def get_lxmf_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -89,7 +91,7 @@ def get_lxmf_address(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
lxmf_address = property_value[prop_value_name].strip() lxmf_address: str = property_value[prop_value_name].strip()
# remove any prefix # remove any prefix
if lxmf_address.startswith('lxmf://'): if lxmf_address.startswith('lxmf://'):
@ -134,10 +136,12 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str,
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -156,10 +160,12 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str,
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -23,14 +23,16 @@ def get_matrix_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
name_value_lower = name_value.lower() name_value_lower: str = name_value.lower()
if not name_value_lower.startswith('matrix'): if not name_value_lower.startswith('matrix'):
if not name_value_lower.startswith('chat'): if not name_value_lower.startswith('chat'):
continue continue
@ -45,7 +47,7 @@ def get_matrix_address(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
address_text = remove_html(property_value[prop_value_name]) address_text: str = remove_html(property_value[prop_value_name])
if 'xmpp' in address_text.lower(): if 'xmpp' in address_text.lower():
continue continue
if 'jabber' in address_text.lower(): if 'jabber' in address_text.lower():
@ -82,10 +84,12 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -115,10 +119,12 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -26,10 +26,12 @@ def get_peertube(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -58,7 +60,7 @@ def get_peertube(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
peertube_text = property_value[prop_value_name] peertube_text: str = property_value[prop_value_name]
if '//peertube.' not in peertube_text: if '//peertube.' not in peertube_text:
continue continue
return remove_html(peertube_text) return remove_html(peertube_text)
@ -79,8 +81,10 @@ def set_peertube(actor_json: {}, peertube: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -98,10 +102,12 @@ def set_peertube(actor_json: {}, peertube: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

44
pgp.py
View File

@ -55,14 +55,16 @@ def get_email_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
name_value_lower = name_value.lower() name_value_lower: str = name_value.lower()
if 'email' not in name_value_lower: if 'email' not in name_value_lower:
if 'e-mail' not in name_value_lower: if 'e-mail' not in name_value_lower:
if 'electronic mail' not in name_value_lower: if 'electronic mail' not in name_value_lower:
@ -75,7 +77,7 @@ def get_email_address(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
value_str = remove_html(property_value[prop_value_name]) value_str: str = remove_html(property_value[prop_value_name])
if '://' in value_str: if '://' in value_str:
continue continue
if '@' not in value_str: if '@' not in value_str:
@ -101,10 +103,12 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -123,7 +127,7 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
value_str = remove_html(property_value[prop_value_name]) value_str: str = remove_html(property_value[prop_value_name])
if 'https://' not in value_str and \ if 'https://' not in value_str and \
'http://' not in value_str: 'http://' not in value_str:
continue continue
@ -140,10 +144,12 @@ def get_pgp_pub_key(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -174,8 +180,10 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -212,15 +220,17 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
actor_json['attachment']: list[dict] = [] actor_json['attachment']: list[dict] = []
# remove any existing value # remove any existing value
property_found = None property_found: dict = None
for property_value in actor_json['attachment']: for property_value in actor_json['attachment']:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -239,10 +249,12 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -296,6 +308,8 @@ def set_deltachat_invite(actor_json: {}, invite_link: str,
continue continue
if not property_value.get('name'): if not property_value.get('name'):
continue continue
if not isinstance(property_value['name'], str):
continue
if not property_value.get('type'): if not property_value.get('type'):
continue continue
if property_value['name'].lower() not in match_strings: if property_value['name'].lower() not in match_strings:
@ -336,10 +350,12 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -360,8 +376,10 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -405,10 +423,12 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue
@ -427,10 +447,12 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -30,10 +30,12 @@ def get_pixelfed(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -47,12 +49,12 @@ def get_pixelfed(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
pixelfed_text = remove_html(property_value[prop_value_name]) pixelfed_text: str = remove_html(property_value[prop_value_name])
if not resembles_url(pixelfed_text): if not resembles_url(pixelfed_text):
if '@' not in pixelfed_text: if '@' not in pixelfed_text:
continue continue
# a pixelfed handle has been given, rather than a url # a pixelfed handle has been given, rather than a url
nickname = get_nickname_from_actor(pixelfed_text) nickname: str = get_nickname_from_actor(pixelfed_text)
domain, port = get_domain_from_actor(pixelfed_text) domain, port = get_domain_from_actor(pixelfed_text)
if not nickname or not domain: if not nickname or not domain:
continue continue
@ -102,8 +104,10 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -123,8 +127,10 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

View File

@ -26,10 +26,12 @@ def get_pronouns(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -43,7 +45,7 @@ def get_pronouns(actor_json: {}) -> str:
continue continue
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
pronouns_text = property_value[prop_value_name] pronouns_text: str = property_value[prop_value_name]
return remove_html(pronouns_text) return remove_html(pronouns_text)
return '' return ''
@ -60,10 +62,12 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'].lower() name_value = property_value['name'].lower()
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'].lower() name_value = property_value['schema:name'].lower()
if not name_value: if not name_value:
continue continue
@ -83,8 +87,10 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None:
continue continue
name_value = None name_value = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue

4
ssb.py
View File

@ -23,10 +23,12 @@ def get_ssb_address(actor_json: {}) -> str:
if not isinstance(property_value, dict): if not isinstance(property_value, dict):
print("WARN: actor attachment is not dict: " + str(property_value)) print("WARN: actor attachment is not dict: " + str(property_value))
continue continue
name_value = None name_value: str = None
if property_value.get('name'): if property_value.get('name'):
if isinstance(property_value['name'], str):
name_value = property_value['name'] name_value = property_value['name']
elif property_value.get('schema:name'): elif property_value.get('schema:name'):
if isinstance(property_value['schema:name'], str):
name_value = property_value['schema:name'] name_value = property_value['schema:name']
if not name_value: if not name_value:
continue continue