mirror of https://gitlab.com/bashrc2/epicyon
Additional user paths
parent
1630163284
commit
4e0869830f
|
@ -1468,7 +1468,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'application/vcard+xml' not in accept_str:
|
||||
return False
|
||||
if path.startswith('/@'):
|
||||
path = path.replace('/@', '/users/', 1)
|
||||
if '/@/' not in path:
|
||||
path = path.replace('/@', '/users/', 1)
|
||||
if not path.startswith('/users/'):
|
||||
self._400()
|
||||
return True
|
||||
|
@ -2579,7 +2580,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
urllib.parse.unquote_plus(mod_text.strip())
|
||||
search_handle = moderation_text
|
||||
if search_handle:
|
||||
if '/@' in search_handle:
|
||||
if '/@' in search_handle and \
|
||||
'/@/' not in search_handle:
|
||||
search_nickname = \
|
||||
get_nickname_from_actor(search_handle)
|
||||
if search_nickname:
|
||||
|
|
32
epicyon.py
32
epicyon.py
|
@ -845,16 +845,18 @@ def _command_options() -> None:
|
|||
origin_domain = argb.domain
|
||||
if debug:
|
||||
print('origin_domain: ' + str(origin_domain))
|
||||
if '@' not in argb.posts:
|
||||
if '/users/' in argb.posts:
|
||||
posts_nickname = get_nickname_from_actor(argb.posts)
|
||||
posts_domain, posts_port = get_domain_from_actor(argb.posts)
|
||||
argb.posts = \
|
||||
get_full_domain(posts_nickname + '@' + posts_domain,
|
||||
posts_port)
|
||||
else:
|
||||
print('Syntax: --posts nickname@domain')
|
||||
if '@' not in argb.posts or '/@/' in argb.posts:
|
||||
posts_nickname = get_nickname_from_actor(argb.posts)
|
||||
if not posts_nickname:
|
||||
print('No nickname found ' + argb.posts)
|
||||
sys.exit()
|
||||
posts_domain, posts_port = get_domain_from_actor(argb.posts)
|
||||
if not posts_domain:
|
||||
print('No domain found ' + argb.posts)
|
||||
sys.exit()
|
||||
argb.posts = \
|
||||
get_full_domain(posts_nickname + '@' + posts_domain,
|
||||
posts_port)
|
||||
if not argb.http:
|
||||
argb.port = 443
|
||||
nickname = argb.posts.split('@')[0]
|
||||
|
@ -1103,6 +1105,18 @@ def _command_options() -> None:
|
|||
origin_domain = argb.domain
|
||||
if debug:
|
||||
print('origin_domain: ' + str(origin_domain))
|
||||
if '@' not in argb.postsraw or '/@/' in argb.postsraw:
|
||||
posts_nickname = get_nickname_from_actor(argb.postsraw)
|
||||
if not posts_nickname:
|
||||
print('No nickname found ' + argb.postsraw)
|
||||
sys.exit()
|
||||
posts_domain, posts_port = get_domain_from_actor(argb.postsraw)
|
||||
if not posts_domain:
|
||||
print('No domain found ' + argb.postsraw)
|
||||
sys.exit()
|
||||
argb.postsraw = \
|
||||
get_full_domain(posts_nickname + '@' + posts_domain,
|
||||
posts_port)
|
||||
if '@' not in argb.postsraw:
|
||||
print('Syntax: --postsraw nickname@domain')
|
||||
sys.exit()
|
||||
|
|
|
@ -953,7 +953,8 @@ def person_lookup(domain: str, path: str, base_dir: str) -> {}:
|
|||
if path.startswith('/users/'):
|
||||
nickname = path.replace('/users/', '', 1)
|
||||
if path.startswith('/@'):
|
||||
nickname = path.replace('/@', '', 1)
|
||||
if '/@/' not in path:
|
||||
nickname = path.replace('/@', '', 1)
|
||||
if not nickname:
|
||||
return None
|
||||
if not is_shared_inbox and not valid_nickname(domain, nickname):
|
||||
|
@ -1026,7 +1027,8 @@ def person_box_json(recent_posts_cache: {},
|
|||
if path.startswith('/users/'):
|
||||
nickname = path.replace('/users/', '', 1).replace('/' + boxname, '')
|
||||
if path.startswith('/@'):
|
||||
nickname = path.replace('/@', '', 1).replace('/' + boxname, '')
|
||||
if '/@/' not in path:
|
||||
nickname = path.replace('/@', '', 1).replace('/' + boxname, '')
|
||||
if not nickname:
|
||||
return None
|
||||
if not valid_nickname(domain, nickname):
|
||||
|
@ -1553,7 +1555,8 @@ def get_actor_json(host_domain: str, handle: str, http: bool, gnunet: bool,
|
|||
prefixes = get_protocol_prefixes()
|
||||
for prefix in prefixes:
|
||||
handle = handle.replace(prefix, '')
|
||||
handle = handle.replace('/@', detected_users_path)
|
||||
if '/@/' not in handle:
|
||||
handle = handle.replace('/@', detected_users_path)
|
||||
paths = get_user_paths()
|
||||
user_path_found = False
|
||||
for user_path in paths:
|
||||
|
|
20
posts.py
20
posts.py
|
@ -210,7 +210,10 @@ def get_user_url(wf_request: {}, source_id: int, debug: bool) -> str:
|
|||
'contains single user instance actor ' +
|
||||
str(source_id) + ' ' + str(link))
|
||||
else:
|
||||
url = link['href'].replace('/@', '/users/')
|
||||
if '/@/' not in link['href']:
|
||||
url = link['href'].replace('/@', '/users/')
|
||||
else:
|
||||
url = link['href']
|
||||
if not contains_invalid_actor_url_chars(url):
|
||||
return url
|
||||
url = link['href']
|
||||
|
@ -1407,14 +1410,18 @@ def _consolidate_actors_list(actors_list: []) -> None:
|
|||
possible_duplicate_actors = []
|
||||
for cc_actor in actors_list:
|
||||
if '/@' in cc_actor:
|
||||
if cc_actor not in possible_duplicate_actors:
|
||||
possible_duplicate_actors.append(cc_actor)
|
||||
if '/@/' not in cc_actor:
|
||||
if cc_actor not in possible_duplicate_actors:
|
||||
possible_duplicate_actors.append(cc_actor)
|
||||
if possible_duplicate_actors:
|
||||
u_paths = get_user_paths()
|
||||
remove_actors = []
|
||||
for cc_actor in possible_duplicate_actors:
|
||||
for usr_path in u_paths:
|
||||
cc_actor_full = cc_actor.replace('/@', usr_path)
|
||||
if '/@/' not in cc_actor:
|
||||
cc_actor_full = cc_actor.replace('/@', usr_path)
|
||||
else:
|
||||
cc_actor_full = cc_actor
|
||||
if cc_actor_full in actors_list:
|
||||
if cc_actor not in remove_actors:
|
||||
remove_actors.append(cc_actor)
|
||||
|
@ -2051,8 +2058,9 @@ def create_blog_post(base_dir: str,
|
|||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
blog_json['object']['url'] = \
|
||||
blog_json['object']['url'].replace('/@', '/users/')
|
||||
if '/@/' not in blog_json['object']['url']:
|
||||
blog_json['object']['url'] = \
|
||||
blog_json['object']['url'].replace('/@', '/users/')
|
||||
_append_citations_to_blog_post(base_dir, nickname, domain, blog_json)
|
||||
|
||||
return blog_json
|
||||
|
|
|
@ -107,7 +107,8 @@ def get_moved_feed(base_dir: str, domain: str, port: int, path: str,
|
|||
nickname = \
|
||||
path.replace('/users/', '', 1).replace('/moved', '')
|
||||
if path.startswith('/@'):
|
||||
nickname = path.replace('/@', '', 1).replace('/moved', '')
|
||||
if '/@/' not in path:
|
||||
nickname = path.replace('/@', '', 1).replace('/moved', '')
|
||||
if not nickname:
|
||||
return None
|
||||
if not valid_nickname(domain, nickname):
|
||||
|
@ -385,7 +386,8 @@ def get_inactive_feed(base_dir: str, domain: str, port: int, path: str,
|
|||
nickname = \
|
||||
path.replace('/users/', '', 1).replace('/inactive', '')
|
||||
if path.startswith('/@'):
|
||||
nickname = path.replace('/@', '', 1).replace('/inactive', '')
|
||||
if '/@/' not in path:
|
||||
nickname = path.replace('/@', '', 1).replace('/inactive', '')
|
||||
if not nickname:
|
||||
return None
|
||||
if not valid_nickname(domain, nickname):
|
||||
|
|
|
@ -484,8 +484,9 @@ def get_shares_feed_for_person(base_dir: str,
|
|||
nickname = \
|
||||
path.replace('/users/', '', 1).replace('/' + shares_file_type, '')
|
||||
if path.startswith('/@'):
|
||||
nickname = \
|
||||
path.replace('/@', '', 1).replace('/' + shares_file_type, '')
|
||||
if '/@/' not in path:
|
||||
nickname = \
|
||||
path.replace('/@', '', 1).replace('/' + shares_file_type, '')
|
||||
if not nickname:
|
||||
return None
|
||||
if not valid_nickname(domain, nickname):
|
||||
|
|
28
utils.py
28
utils.py
|
@ -1373,15 +1373,16 @@ def get_nickname_from_actor(actor: str) -> str:
|
|||
if '/' not in nick_str:
|
||||
return nick_str
|
||||
return nick_str.split('/')[0]
|
||||
if '/@' in actor:
|
||||
# https://domain/@nick
|
||||
nick_str = actor.split('/@')[1]
|
||||
if '/' in nick_str:
|
||||
nick_str = nick_str.split('/')[0]
|
||||
return nick_str
|
||||
if '@' in actor:
|
||||
nick_str = actor.split('@')[0]
|
||||
return nick_str
|
||||
if '/@/' not in actor:
|
||||
if '/@' in actor:
|
||||
# https://domain/@nick
|
||||
nick_str = actor.split('/@')[1]
|
||||
if '/' in nick_str:
|
||||
nick_str = nick_str.split('/')[0]
|
||||
return nick_str
|
||||
if '@' in actor:
|
||||
nick_str = actor.split('@')[0]
|
||||
return nick_str
|
||||
if '://' in actor:
|
||||
domain = actor.split('://')[1]
|
||||
if '/' in domain:
|
||||
|
@ -1401,7 +1402,7 @@ def get_user_paths() -> []:
|
|||
"""
|
||||
return ('/users/', '/profile/', '/accounts/', '/channel/', '/u/',
|
||||
'/c/', '/video-channels/', '/author/', '/activitypub/',
|
||||
'/actors/', '/snac/')
|
||||
'/actors/', '/snac/', '/@/', '/~/')
|
||||
|
||||
|
||||
def get_group_paths() -> []:
|
||||
|
@ -1425,11 +1426,11 @@ def get_domain_from_actor(actor: str) -> (str, int):
|
|||
for prefix in prefixes:
|
||||
domain = domain.replace(prefix, '')
|
||||
break
|
||||
if '/@' in actor:
|
||||
if '/@' in actor and '/@/' not in actor:
|
||||
domain = actor.split('/@')[0]
|
||||
for prefix in prefixes:
|
||||
domain = domain.replace(prefix, '')
|
||||
elif '@' in actor:
|
||||
elif '@' in actor and '/@/' not in actor:
|
||||
domain = actor.split('@')[1].strip()
|
||||
else:
|
||||
domain = actor
|
||||
|
@ -3709,7 +3710,8 @@ def replace_users_with_at(actor: str) -> str:
|
|||
u_paths = get_user_paths()
|
||||
for path in u_paths:
|
||||
if path in actor:
|
||||
actor = actor.replace(path, '/@')
|
||||
if '/@/' not in actor:
|
||||
actor = actor.replace(path, '/@')
|
||||
break
|
||||
return actor
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ def _parse_handle(handle: str) -> (str, str, bool):
|
|||
handle_str = handle_str.replace(prefix, '')
|
||||
|
||||
# try domain/@nick
|
||||
if '/@' in handle:
|
||||
if '/@' in handle and '/@/' not in handle:
|
||||
domain, nickname = handle_str.split('/@')
|
||||
return nickname, domain, False
|
||||
|
||||
|
|
Loading…
Reference in New Issue