mirror of https://gitlab.com/bashrc2/epicyon
Option to show labels on actor
parent
3241c01e52
commit
e6f8f44777
29
epicyon.py
29
epicyon.py
|
|
@ -75,6 +75,7 @@ from src.tests import test_update_actor
|
|||
from src.tests import run_all_tests
|
||||
from src.auth import store_basic_credentials
|
||||
from src.auth import create_password
|
||||
from src.utils import get_labels_from_json
|
||||
from src.utils import resembles_domain
|
||||
from src.utils import string_starts_with
|
||||
from src.utils import is_yggdrasil_url
|
||||
|
|
@ -431,6 +432,9 @@ def _command_options() -> None:
|
|||
parser.add_argument('--actor', dest='actor', type=str,
|
||||
default=None,
|
||||
help='Show the json actor the given handle')
|
||||
parser.add_argument('--labels', dest='labels', type=str,
|
||||
default=None,
|
||||
help='Show labels for the given actor')
|
||||
parser.add_argument('--posts', dest='posts', type=str,
|
||||
default=None,
|
||||
help='Show posts for the given handle')
|
||||
|
|
@ -3120,6 +3124,31 @@ def _command_options() -> None:
|
|||
mitm_servers)
|
||||
sys.exit()
|
||||
|
||||
if argb.labels:
|
||||
# returns any labels attached to an actor
|
||||
if not domain:
|
||||
domain = get_config_param(base_dir, 'domain')
|
||||
signing_priv_key_pem = get_instance_actor_key(base_dir, domain)
|
||||
if debug:
|
||||
print('base_dir: ' + str(base_dir))
|
||||
if signing_priv_key_pem:
|
||||
print('Obtained instance actor signing key')
|
||||
else:
|
||||
print('Did not obtain instance actor key for ' + domain)
|
||||
if argb.labels.startswith('@'):
|
||||
argb.labels = argb.actor[1:]
|
||||
mitm_servers: list[str] = []
|
||||
quiet: bool = True
|
||||
post_json_object, _ = \
|
||||
get_actor_json(domain, argb.labels, argb.http, argb.gnunet,
|
||||
argb.ipfs, argb.ipns,
|
||||
debug, quiet, signing_priv_key_pem, None,
|
||||
mitm_servers)
|
||||
if post_json_object:
|
||||
labels_list = get_labels_from_json(post_json_object)
|
||||
pprint(labels_list)
|
||||
sys.exit()
|
||||
|
||||
if argb.followers:
|
||||
original_actor = argb.followers
|
||||
if '/@' in argb.followers or \
|
||||
|
|
|
|||
|
|
@ -1885,6 +1885,8 @@ def get_person_notes_endpoint(base_dir: str, nickname: str, domain: str,
|
|||
def _detect_users_path(url: str) -> []:
|
||||
"""Tries to detect the /users/ path
|
||||
"""
|
||||
if not url:
|
||||
return '/users/'
|
||||
if '/' not in url:
|
||||
return '/users/'
|
||||
users_paths = get_user_paths()
|
||||
|
|
|
|||
|
|
@ -4460,15 +4460,15 @@ def get_labels_from_json(json_object: {}) -> []:
|
|||
"""Returns labels attached to an actor or post
|
||||
"""
|
||||
tags_list: list[dict] = []
|
||||
if 'attachment' in json_object:
|
||||
if isinstance(json_object['attachment'], list):
|
||||
tags_list = json_object['attachment']
|
||||
obj: dict = json_object
|
||||
if has_object_dict(json_object):
|
||||
obj = json_object['object']
|
||||
if 'tag' in obj:
|
||||
if isinstance(obj['tag'], list):
|
||||
tags_list = obj['tag']
|
||||
if 'attachment' in json_object:
|
||||
if isinstance(json_object['attachment'], list):
|
||||
tags_list = json_object['attachment']
|
||||
if not tags_list:
|
||||
return []
|
||||
labels: list[str] = []
|
||||
|
|
@ -4477,7 +4477,7 @@ def get_labels_from_json(json_object: {}) -> []:
|
|||
continue
|
||||
if 'type' not in tag_dict or 'name' not in tag_dict:
|
||||
continue
|
||||
if 'value' not in tag_dict or 'href' not in tag_dict:
|
||||
if 'value' not in tag_dict and 'href' not in tag_dict:
|
||||
continue
|
||||
if not isinstance(tag_dict['type'], str):
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue