Handling matrix addresses

main
Bob Mottram 2024-08-12 10:24:49 +01:00
parent d26e172ee6
commit a5efcd3836
2 changed files with 20 additions and 10 deletions

View File

@ -1,7 +1,6 @@
# Roadmap
## UX
* Minimize button shows different icons or highlighting
* Layout of buttons on person options screen
## Groups
@ -11,7 +10,6 @@
## Questions
* Still not implemented ideally
* Instance-only questions
* Active polls screen?
* Questions more integrated into overall organization

View File

@ -27,7 +27,9 @@ def get_matrix_address(actor_json: {}) -> str:
name_value = property_value['schema:name']
if not name_value:
continue
if not name_value.lower().startswith('matrix'):
name_value_lower = name_value.lower()
if not name_value_lower.startswith('matrix'):
if not name_value_lower.startswith('chat'):
continue
if not property_value.get('type'):
continue
@ -37,15 +39,25 @@ def get_matrix_address(actor_json: {}) -> str:
continue
if not property_value['type'].endswith('PropertyValue'):
continue
if '@' not in property_value[prop_value_name]:
address_text = property_value[prop_value_name]
if 'matrix' in address_text:
address_text = address_text.split('matrix')[1]
elif 'Matrix' in address_text:
address_text = address_text.split('Matrix')[1]
if '@' not in address_text:
continue
if not property_value[prop_value_name].startswith('@'):
address_text = '@' + address_text.split('@', 1)[1]
if ' ' in address_text:
address_text = address_text.split(' ')[0]
if '|' in address_text:
address_text = address_text.split('|')[0]
if ',' in address_text:
address_text = address_text.split(',')[0]
if ':' not in address_text:
continue
if ':' not in property_value[prop_value_name]:
if '"' in address_text:
continue
if '"' in property_value[prop_value_name]:
continue
return remove_html(property_value[prop_value_name])
return remove_html(address_text)
return ''