mirror of https://gitlab.com/bashrc2/epicyon
Function for if an actor is indexable by a search engine
parent
f685f82dd9
commit
8fa9189518
|
@ -19,6 +19,7 @@ from utils import no_of_accounts
|
|||
from utils import get_status_count
|
||||
from utils import lines_in_file
|
||||
from utils import data_dir
|
||||
from utils import account_is_indexable
|
||||
|
||||
|
||||
def _meta_data_instance_v1(show_accounts: bool,
|
||||
|
@ -220,10 +221,7 @@ def _get_masto_api_v1account(base_dir: str, nickname: str, domain: str,
|
|||
joined_date = "2016-10-05T10:30:00Z"
|
||||
if account_json.get('published'):
|
||||
joined_date = account_json['published']
|
||||
noindex = True
|
||||
if 'indexable' in account_json:
|
||||
if account_json['indexable'] is True:
|
||||
noindex = False
|
||||
noindex = not account_is_indexable(account_json)
|
||||
discoverable = True
|
||||
if 'discoverable' in account_json:
|
||||
if account_json['discoverable'] is False:
|
||||
|
|
|
@ -21,6 +21,7 @@ from utils import get_audio_extensions
|
|||
from utils import get_image_mime_type
|
||||
from utils import lines_in_file
|
||||
from utils import data_dir
|
||||
from utils import account_is_indexable
|
||||
|
||||
|
||||
def _get_masto_api_v2id_from_nickname(nickname: str) -> int:
|
||||
|
@ -96,10 +97,7 @@ def _meta_data_instance_v2(show_accounts: bool,
|
|||
image_url = remove_html(url_str)
|
||||
thumbnail_url = http_prefix + '://' + domain_full + '/login.png'
|
||||
admin_email = None
|
||||
noindex = True
|
||||
if 'indexable' in admin_actor:
|
||||
if admin_actor['indexable'] is True:
|
||||
noindex = False
|
||||
noindex = not account_is_indexable(admin_actor)
|
||||
discoverable = True
|
||||
if 'discoverable' in admin_actor:
|
||||
if admin_actor['discoverable'] is False:
|
||||
|
|
|
@ -37,6 +37,7 @@ from roles import set_role
|
|||
from roles import actor_roles_from_list
|
||||
from roles import get_actor_roles_list
|
||||
from media import process_meta_data
|
||||
from utils import account_is_indexable
|
||||
from utils import get_image_mime_type
|
||||
from utils import get_instance_url
|
||||
from utils import get_url_from_post
|
||||
|
@ -218,9 +219,7 @@ def get_actor_update_json(actor_json: {}) -> {}:
|
|||
memorial = False
|
||||
if actor_json.get('memorial'):
|
||||
memorial = True
|
||||
indexable = False
|
||||
if actor_json.get('indexable'):
|
||||
indexable = True
|
||||
indexable = account_is_indexable(actor_json)
|
||||
searchable_by = []
|
||||
if actor_json.get('searchableBy'):
|
||||
if isinstance(actor_json['searchableBy'], list):
|
||||
|
|
16
utils.py
16
utils.py
|
@ -5683,3 +5683,19 @@ def replace_strings(text: str, replacements: {}) -> str:
|
|||
for orig_str, new_str in replacements.items():
|
||||
text = text.replace(orig_str, new_str)
|
||||
return text
|
||||
|
||||
|
||||
def account_is_indexable(actor_json: {}) -> bool:
|
||||
"""Returns true if the given actor is indexable
|
||||
"""
|
||||
if 'indexable' not in actor_json:
|
||||
return False
|
||||
if isinstance(actor_json['indexable'], bool):
|
||||
return actor_json['indexable']
|
||||
if isinstance(actor_json['indexable'], list):
|
||||
if '#Public' in str(actor_json['indexable']):
|
||||
return True
|
||||
elif isinstance(actor_json['indexable'], str):
|
||||
if '#Public' in actor_json['indexable']:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue