Generalize attachment properties on actors

main
Bob Mottram 2022-05-11 18:39:23 +01:00
parent fc2697c976
commit 471c9d4a72
1 changed files with 14 additions and 8 deletions

View File

@ -38,6 +38,7 @@ from roles import set_role
from roles import set_rolesFromList from roles import set_rolesFromList
from roles import get_actor_roles_list from roles import get_actor_roles_list
from media import process_meta_data from media import process_meta_data
from utils import get_attachment_property_value
from utils import get_nickname_from_actor from utils import get_nickname_from_actor
from utils import remove_html from utils import remove_html
from utils import contains_invalid_chars from utils import contains_invalid_chars
@ -1789,10 +1790,14 @@ def valid_sending_actor(session, base_dir: str,
continue continue
if isinstance(tag['name'], str): if isinstance(tag['name'], str):
bio_str += ' ' + tag['name'] bio_str += ' ' + tag['name']
if tag.get('value'): prop_value_name, _ = \
get_attachment_property_value(tag)
if not prop_value_name:
continue continue
if isinstance(tag['value'], str): if tag.get(prop_value_name):
bio_str += ' ' + tag['value'] continue
if isinstance(tag[prop_value_name], str):
bio_str += ' ' + tag[prop_value_name]
if actor_json.get('name'): if actor_json.get('name'):
bio_str += ' ' + remove_html(actor_json['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']: for tag in actor_json['attachment']:
if not isinstance(tag, dict): if not isinstance(tag, dict):
continue continue
if not tag.get('name'): if not tag.get('name') and not tag.get('schema:name'):
continue continue
no_of_tags += 1 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 tags_without_value += 1
continue continue
if not isinstance(tag['value'], str): if not isinstance(tag[prop_value_name], str):
tags_without_value += 1 tags_without_value += 1
continue continue
if not tag['value'].strip(): if not tag[prop_value_name].strip():
tags_without_value += 1 tags_without_value += 1
continue continue
if len(tag['value']) < 2: if len(tag[prop_value_name]) < 2:
tags_without_value += 1 tags_without_value += 1
continue continue
if no_of_tags > 0: if no_of_tags > 0: