From 7e03a33d33c701ba182f4b967b4e9849aa7fb85c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 12 Aug 2024 10:34:27 +0100 Subject: [PATCH] Avoid confusion between xmpp and matrix addresses --- matrix.py | 4 ++++ xmpp.py | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/matrix.py b/matrix.py index 34e301c58..197faa605 100644 --- a/matrix.py +++ b/matrix.py @@ -40,6 +40,10 @@ def get_matrix_address(actor_json: {}) -> str: if not property_value['type'].endswith('PropertyValue'): continue 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: address_text = address_text.split('matrix')[1] elif 'Matrix' in address_text: diff --git a/xmpp.py b/xmpp.py index 5726edfb0..183e14902 100644 --- a/xmpp.py +++ b/xmpp.py @@ -40,14 +40,18 @@ def get_xmpp_address(actor_json: {}) -> str: if not property_value['type'].endswith('PropertyValue') and \ not property_value['type'] == 'Link': continue - if '@' not in property_value[prop_value_name]: + address_text = property_value[prop_value_name] + if 'matrix' in address_text.lower(): continue - if '"' in property_value[prop_value_name]: + if '@' not in address_text: continue - if property_value[prop_value_name].startswith('xmpp://'): - property_value[prop_value_name] = \ - property_value[prop_value_name].split('xmpp://', 1)[1] - return remove_html(property_value[prop_value_name]) + if '.' not in address_text: + continue + if '"' in address_text: + continue + if address_text.startswith('xmpp://'): + address_text = address_text.split('xmpp://', 1)[1] + return remove_html(address_text) return ''