Avoid confusion between xmpp and matrix addresses

main
Bob Mottram 2024-08-12 10:34:27 +01:00
parent a5efcd3836
commit 7e03a33d33
2 changed files with 14 additions and 6 deletions

View File

@ -40,6 +40,10 @@ def get_matrix_address(actor_json: {}) -> str:
if not property_value['type'].endswith('PropertyValue'): if not property_value['type'].endswith('PropertyValue'):
continue continue
address_text = property_value[prop_value_name] address_text = property_value[prop_value_name]
if 'xmpp' in address_text.lower():
continue
if 'jabber' in address_text.lower():
continue
if 'matrix' in address_text: if 'matrix' in address_text:
address_text = address_text.split('matrix')[1] address_text = address_text.split('matrix')[1]
elif 'Matrix' in address_text: elif 'Matrix' in address_text:

16
xmpp.py
View File

@ -40,14 +40,18 @@ def get_xmpp_address(actor_json: {}) -> str:
if not property_value['type'].endswith('PropertyValue') and \ if not property_value['type'].endswith('PropertyValue') and \
not property_value['type'] == 'Link': not property_value['type'] == 'Link':
continue continue
if '@' not in property_value[prop_value_name]: address_text = property_value[prop_value_name]
if 'matrix' in address_text.lower():
continue continue
if '"' in property_value[prop_value_name]: if '@' not in address_text:
continue continue
if property_value[prop_value_name].startswith('xmpp://'): if '.' not in address_text:
property_value[prop_value_name] = \ continue
property_value[prop_value_name].split('xmpp://', 1)[1] if '"' in address_text:
return remove_html(property_value[prop_value_name]) continue
if address_text.startswith('xmpp://'):
address_text = address_text.split('xmpp://', 1)[1]
return remove_html(address_text)
return '' return ''