mirror of https://gitlab.com/bashrc2/epicyon
Add alternate domains to alsoKnownAs
parent
438b6d59ce
commit
2f58bade3a
|
@ -60,6 +60,7 @@ from donate import get_donation_url
|
|||
from donate import set_donation_url
|
||||
from donate import get_website
|
||||
from donate import set_website
|
||||
from person import add_alternate_domains
|
||||
from person import add_actor_update_timestamp
|
||||
from person import set_person_notes
|
||||
from person import get_default_person_context
|
||||
|
@ -428,7 +429,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
def _convert_domains(self, calling_domain, referer_domain,
|
||||
msg_str: str) -> str:
|
||||
"""Convert domains to onion or i2p
|
||||
"""Convert domains to onion or i2p, depending upon who is asking
|
||||
"""
|
||||
curr_http_prefix = self.server.http_prefix + '://'
|
||||
if is_onion_request(calling_domain, referer_domain,
|
||||
|
@ -13428,6 +13429,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actor_json = person_lookup(domain, path, base_dir)
|
||||
if not actor_json:
|
||||
return False
|
||||
add_alternate_domains(actor_json, domain, onion_domain, i2p_domain)
|
||||
if self._request_http():
|
||||
curr_session = \
|
||||
self._establish_session("showPersonProfile",
|
||||
|
|
26
person.py
26
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_nickname_from_actor
|
||||
from utils import remove_html
|
||||
from utils import contains_invalid_chars
|
||||
from utils import replace_users_with_at
|
||||
|
@ -861,6 +862,31 @@ def person_upgrade_actor(base_dir: str, person_json: {},
|
|||
save_json(person_json, actor_cache_filename)
|
||||
|
||||
|
||||
def add_alternate_domains(actor_json: {}, domain: str,
|
||||
onion_domain: str, i2p_domain: str) -> None:
|
||||
"""Adds alternate onion and/or i2p domains to alsoKnownAs
|
||||
"""
|
||||
if not onion_domain and not i2p_domain:
|
||||
return
|
||||
if not actor_json.get('id'):
|
||||
return
|
||||
if domain not in actor_json['id']:
|
||||
return
|
||||
nickname = get_nickname_from_actor(actor_json['id'])
|
||||
if not nickname:
|
||||
return
|
||||
if 'alsoKnownAs' not in actor_json:
|
||||
actor_json['alsoKnownAs'] = []
|
||||
if onion_domain:
|
||||
onion_actor = 'http://' + onion_domain + '/users/' + nickname
|
||||
if onion_actor not in actor_json['alsoKnownAs']:
|
||||
actor_json['alsoKnownAs'].append(onion_actor)
|
||||
if i2p_domain:
|
||||
i2p_actor = 'http://' + i2p_domain + '/users/' + nickname
|
||||
if i2p_actor not in actor_json['alsoKnownAs']:
|
||||
actor_json['alsoKnownAs'].append(i2p_actor)
|
||||
|
||||
|
||||
def person_lookup(domain: str, path: str, base_dir: str) -> {}:
|
||||
"""Lookup the person for an given nickname
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue