From 471c9d4a7298d203d815bf0f4547b7b46cfe83ba Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 11 May 2022 18:39:23 +0100 Subject: [PATCH] Generalize attachment properties on actors --- person.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/person.py b/person.py index 941aa43b5..ad29dee32 100644 --- a/person.py +++ b/person.py @@ -38,6 +38,7 @@ from roles import set_role from roles import set_rolesFromList from roles import get_actor_roles_list from media import process_meta_data +from utils import get_attachment_property_value from utils import get_nickname_from_actor from utils import remove_html from utils import contains_invalid_chars @@ -1789,10 +1790,14 @@ def valid_sending_actor(session, base_dir: str, continue if isinstance(tag['name'], str): bio_str += ' ' + tag['name'] - if tag.get('value'): + prop_value_name, _ = \ + get_attachment_property_value(tag) + if not prop_value_name: continue - if isinstance(tag['value'], str): - bio_str += ' ' + tag['value'] + if tag.get(prop_value_name): + continue + if isinstance(tag[prop_value_name], str): + bio_str += ' ' + tag[prop_value_name] if actor_json.get('name'): bio_str += ' ' + remove_html(actor_json['name']) @@ -1814,19 +1819,20 @@ def valid_sending_actor(session, base_dir: str, for tag in actor_json['attachment']: if not isinstance(tag, dict): continue - if not tag.get('name'): + if not tag.get('name') and not tag.get('schema:name'): continue no_of_tags += 1 - if not tag.get('value'): + prop_value_name, _ = get_attachment_property_value(tag) + if not prop_value_name: tags_without_value += 1 continue - if not isinstance(tag['value'], str): + if not isinstance(tag[prop_value_name], str): tags_without_value += 1 continue - if not tag['value'].strip(): + if not tag[prop_value_name].strip(): tags_without_value += 1 continue - if len(tag['value']) < 2: + if len(tag[prop_value_name]) < 2: tags_without_value += 1 continue if no_of_tags > 0: