mirror of https://gitlab.com/bashrc2/epicyon
Check property types
parent
3d7cf796be
commit
258562f8aa
18
briar.py
18
briar.py
|
|
@ -23,11 +23,13 @@ def get_briar_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('briar'):
|
||||
|
|
@ -86,12 +88,12 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
|
|||
actor_json['attachment']: list[dict] = []
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
property_found: dict = None
|
||||
for property_value in actor_json['attachment']:
|
||||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
|
|
@ -115,9 +117,11 @@ def set_briar_address(actor_json: {}, briar_address: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
22
cwtch.py
22
cwtch.py
|
|
@ -23,11 +23,13 @@ def get_cwtch_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('cwtch'):
|
||||
|
|
@ -77,11 +79,13 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -101,9 +105,11 @@ def set_cwtch_address(actor_json: {}, cwtch_address: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
26
discord.py
26
discord.py
|
|
@ -26,11 +26,13 @@ def get_discord(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not string_contains(name_value, discord_fieldnames):
|
||||
|
|
@ -43,7 +45,7 @@ def get_discord(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
discord_text = property_value[prop_value_name]
|
||||
discord_text: str = property_value[prop_value_name]
|
||||
return remove_html(discord_text)
|
||||
return ''
|
||||
|
||||
|
|
@ -55,16 +57,18 @@ def set_discord(actor_json: {}, discord: str) -> None:
|
|||
actor_json['attachment']: list[dict] = []
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
property_found: dict = None
|
||||
for property_value in actor_json['attachment']:
|
||||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -81,11 +85,13 @@ def set_discord(actor_json: {}, discord: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
31
donate.py
31
donate.py
|
|
@ -36,14 +36,16 @@ def get_donation_url(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
name_value_lower = name_value.lower()
|
||||
name_value_lower: str = name_value.lower()
|
||||
found: bool = False
|
||||
for donation_type_str in donation_type_list:
|
||||
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'):
|
||||
continue
|
||||
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:
|
||||
donate_url = donate_url.split('"')[0]
|
||||
donate_url = remove_html(donate_url)
|
||||
return remove_link_tracking(donate_url)
|
||||
else:
|
||||
donate_url = remove_html(property_value[prop_value_name])
|
||||
donate_url: str = remove_html(property_value[prop_value_name])
|
||||
if ' ' in donate_url:
|
||||
donate_url = donate_url.split(' ')[0]
|
||||
if '://' in donate_url:
|
||||
|
|
@ -108,11 +111,13 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -135,11 +140,13 @@ def set_donation_url(actor_json: {}, donate_url: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
22
enigma.py
22
enigma.py
|
|
@ -23,11 +23,13 @@ def get_enigma_pub_key(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('enigma'):
|
||||
|
|
@ -60,11 +62,13 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -84,9 +88,11 @@ def set_enigma_pub_key(actor_json: {}, enigma_pub_key: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
10
git.py
10
git.py
|
|
@ -240,11 +240,13 @@ def get_repo_url(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if name_value.lower() not in repo_type:
|
||||
|
|
@ -268,7 +270,7 @@ def get_repo_url(actor_json: {}) -> str:
|
|||
repo_url = remove_html(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']:
|
||||
if not isinstance(property_value, dict):
|
||||
|
|
|
|||
26
lxmf.py
26
lxmf.py
|
|
@ -70,11 +70,13 @@ def get_lxmf_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
name_value_lower = name_value.lower()
|
||||
|
|
@ -89,7 +91,7 @@ def get_lxmf_address(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
lxmf_address = property_value[prop_value_name].strip()
|
||||
lxmf_address: str = property_value[prop_value_name].strip()
|
||||
|
||||
# remove any prefix
|
||||
if lxmf_address.startswith('lxmf://'):
|
||||
|
|
@ -134,11 +136,13 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str,
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -156,11 +160,13 @@ def set_lxmf_address(base_dir: str, nickname: str, domain: str,
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
28
matrix.py
28
matrix.py
|
|
@ -23,14 +23,16 @@ def get_matrix_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
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('chat'):
|
||||
continue
|
||||
|
|
@ -45,7 +47,7 @@ def get_matrix_address(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
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():
|
||||
continue
|
||||
if 'jabber' in address_text.lower():
|
||||
|
|
@ -82,11 +84,13 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -115,11 +119,13 @@ def set_matrix_address(actor_json: {}, matrix_address: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
24
peertube.py
24
peertube.py
|
|
@ -26,11 +26,13 @@ def get_peertube(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not string_contains(name_value, peertube_fieldnames):
|
||||
|
|
@ -58,7 +60,7 @@ def get_peertube(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
peertube_text = property_value[prop_value_name]
|
||||
peertube_text: str = property_value[prop_value_name]
|
||||
if '//peertube.' not in peertube_text:
|
||||
continue
|
||||
return remove_html(peertube_text)
|
||||
|
|
@ -79,9 +81,11 @@ def set_peertube(actor_json: {}, peertube: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -98,11 +102,13 @@ def set_peertube(actor_json: {}, peertube: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
84
pgp.py
84
pgp.py
|
|
@ -55,14 +55,16 @@ def get_email_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
name_value_lower = name_value.lower()
|
||||
name_value_lower: str = name_value.lower()
|
||||
if 'email' not in name_value_lower:
|
||||
if 'e-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
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
value_str = remove_html(property_value[prop_value_name])
|
||||
value_str: str = remove_html(property_value[prop_value_name])
|
||||
if '://' in value_str:
|
||||
continue
|
||||
if '@' not in value_str:
|
||||
|
|
@ -101,11 +103,13 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
found: bool = False
|
||||
|
|
@ -123,7 +127,7 @@ def get_deltachat_invite(actor_json: {}, translate: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
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 \
|
||||
'http://' not in value_str:
|
||||
continue
|
||||
|
|
@ -140,11 +144,13 @@ def get_pgp_pub_key(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('pgp'):
|
||||
|
|
@ -174,9 +180,11 @@ def get_pgp_fingerprint(actor_json: {}) -> str:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('openpgp'):
|
||||
|
|
@ -212,16 +220,18 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
|
|||
actor_json['attachment']: list[dict] = []
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
property_found: dict = None
|
||||
for property_value in actor_json['attachment']:
|
||||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -239,11 +249,13 @@ def set_email_address(actor_json: {}, email_address: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -296,6 +308,8 @@ def set_deltachat_invite(actor_json: {}, invite_link: str,
|
|||
continue
|
||||
if not property_value.get('name'):
|
||||
continue
|
||||
if not isinstance(property_value['name'], str):
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
if property_value['name'].lower() not in match_strings:
|
||||
|
|
@ -336,11 +350,13 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -360,9 +376,11 @@ def set_pgp_pub_key(actor_json: {}, pgp_pub_key: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -405,11 +423,13 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -427,11 +447,13 @@ def set_pgp_fingerprint(actor_json: {}, fingerprint: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
24
pixelfed.py
24
pixelfed.py
|
|
@ -30,11 +30,13 @@ def get_pixelfed(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not string_contains(name_value, pixelfed_fieldnames):
|
||||
|
|
@ -47,12 +49,12 @@ def get_pixelfed(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
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 in pixelfed_text:
|
||||
continue
|
||||
# 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)
|
||||
if not nickname or not domain:
|
||||
continue
|
||||
|
|
@ -102,9 +104,11 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -123,9 +127,11 @@ def set_pixelfed(actor_json: {}, pixelfed: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
24
pronouns.py
24
pronouns.py
|
|
@ -26,11 +26,13 @@ def get_pronouns(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not string_contains(name_value, pronoun_fieldnames):
|
||||
|
|
@ -43,7 +45,7 @@ def get_pronouns(actor_json: {}) -> str:
|
|||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
pronouns_text = property_value[prop_value_name]
|
||||
pronouns_text: str = property_value[prop_value_name]
|
||||
return remove_html(pronouns_text)
|
||||
return ''
|
||||
|
||||
|
|
@ -60,11 +62,13 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
@ -83,9 +87,11 @@ def set_pronouns(actor_json: {}, pronouns: str) -> None:
|
|||
continue
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
|
|
|
|||
8
ssb.py
8
ssb.py
|
|
@ -23,11 +23,13 @@ def get_ssb_address(actor_json: {}) -> str:
|
|||
if not isinstance(property_value, dict):
|
||||
print("WARN: actor attachment is not dict: " + str(property_value))
|
||||
continue
|
||||
name_value = None
|
||||
name_value: str = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
if isinstance(property_value['name'], str):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if isinstance(property_value['schema:name'], str):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not name_value.lower().startswith('ssb'):
|
||||
|
|
|
|||
Loading…
Reference in New Issue