Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-02-26 23:36:21 +00:00
commit abcc19619a
6 changed files with 30 additions and 11 deletions

View File

@ -369,7 +369,7 @@ from filters import add_global_filter
from filters import remove_global_filter from filters import remove_global_filter
from context import has_valid_context from context import has_valid_context
from context import get_individual_post_context from context import get_individual_post_context
from speaker import get_ssm_lbox from speaker import get_ssml_box
from city import get_spoofed_city from city import get_spoofed_city
from fitnessFunctions import fitness_performance from fitnessFunctions import fitness_performance
from fitnessFunctions import fitness_thread from fitnessFunctions import fitness_thread
@ -696,7 +696,7 @@ class PubServer(BaseHTTPRequestHandler):
return True return True
return False return False
def _signed_ge_tkey_id(self) -> str: def _signed_get_key_id(self) -> str:
"""Returns the actor from the signed GET key_id """Returns the actor from the signed GET key_id
""" """
signature = None signature = None
@ -744,7 +744,7 @@ class PubServer(BaseHTTPRequestHandler):
if not self.server.secure_mode and not force: if not self.server.secure_mode and not force:
return True return True
key_id = self._signed_ge_tkey_id() key_id = self._signed_get_key_id()
if not key_id: if not key_id:
if self.server.debug: if self.server.debug:
print('AUTH: secure mode, ' + print('AUTH: secure mode, ' +
@ -852,6 +852,10 @@ class PubServer(BaseHTTPRequestHandler):
return return
self.send_header('X-AP-Instance-ID', self.server.instance_id) self.send_header('X-AP-Instance-ID', self.server.instance_id)
self.send_header('X-Clacks-Overhead', 'GNU Natalie Nguyen') self.send_header('X-Clacks-Overhead', 'GNU Natalie Nguyen')
self.send_header('User-Agent',
'Epicyon/' + __version__ +
'; +' + self.server.http_prefix + '://' +
self.server.domain_full + '/')
if cookie: if cookie:
cookie_str = cookie cookie_str = cookie
if 'HttpOnly;' not in cookie_str: if 'HttpOnly;' not in cookie_str:
@ -12823,6 +12827,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.fitness, self.server.fitness,
'_GET', '_show_person_profile', '_GET', '_show_person_profile',
self.server.debug) self.server.debug)
if self.server.debug:
print('DEBUG: html actor sent')
else: else:
if self._secure_mode(): if self._secure_mode():
accept_str = self.headers['Accept'] accept_str = self.headers['Accept']
@ -12843,6 +12849,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.fitness, self.server.fitness,
'_GET', '_show_person_profile json', '_GET', '_show_person_profile json',
self.server.debug) self.server.debug)
if self.server.debug:
print('DEBUG: json actor sent')
else: else:
self._404() self._404()
return True return True
@ -13986,6 +13994,7 @@ class PubServer(BaseHTTPRequestHandler):
# instance actor # instance actor
if self.path == '/actor' or \ if self.path == '/actor' or \
self.path == '/users/instance.actor' or \
self.path == '/users/actor' or \ self.path == '/users/actor' or \
self.path == '/Actor' or \ self.path == '/Actor' or \
self.path == '/users/Actor': self.path == '/users/Actor':
@ -14067,9 +14076,10 @@ class PubServer(BaseHTTPRequestHandler):
authorized = self._is_authorized() authorized = self._is_authorized()
if self.server.debug: if self.server.debug:
if authorized: if authorized:
print('GET Authorization granted') print('GET Authorization granted ' + self.path)
else: else:
print('GET Not authorized') print('GET Not authorized ' + self.path + ' ' +
str(self.headers))
fitness_performance(getreq_start_time, self.server.fitness, fitness_performance(getreq_start_time, self.server.fitness,
'_GET', 'isAuthorized', '_GET', 'isAuthorized',
@ -14500,7 +14510,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.debug) self.server.debug)
else: else:
xml_str = \ xml_str = \
get_ssm_lbox(self.server.base_dir, get_ssml_box(self.server.base_dir,
self.path, self.server.domain, self.path, self.server.domain,
self.server.system_language, self.server.system_language,
self.server.instanceTitle, self.server.instanceTitle,

View File

@ -1523,8 +1523,13 @@ def get_actor_json(hostDomain: str, handle: str, http: bool, gnunet: bool,
person_url = None person_url = None
wf_request = None wf_request = None
if '://' in original_actor and \ original_actor_lower = original_actor.lower()
original_actor.lower().endswith('/actor'): ends_with_instance_actor = False
if original_actor_lower.endswith('/actor') or \
original_actor_lower.endswith('/instance.actor'):
ends_with_instance_actor = True
if '://' in original_actor and ends_with_instance_actor:
if debug: if debug:
print(original_actor + ' is an instance actor') print(original_actor + ' is an instance actor')
person_url = original_actor person_url = original_actor

View File

@ -2759,7 +2759,8 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
print("to_person_id: " + str(to_person_id)) print("to_person_id: " + str(to_person_id))
print("shared_inbox_url: " + str(shared_inbox_url)) print("shared_inbox_url: " + str(shared_inbox_url))
if inbox_url: if inbox_url:
if inbox_url.endswith('/actor/inbox'): if inbox_url.endswith('/actor/inbox') or \
inbox_url.endswith('/instance.actor/inbox'):
inbox_url = shared_inbox_url inbox_url = shared_inbox_url
if not inbox_url: if not inbox_url:

View File

@ -348,7 +348,7 @@ def _speaker_endpoint_ssml(display_name: str, summary: str,
'</speak>\n' '</speak>\n'
def get_ssm_lbox(base_dir: str, path: str, def get_ssml_box(base_dir: str, path: str,
domain: str, domain: str,
system_language: str, system_language: str,
instance_title: str, instance_title: str,

View File

@ -3047,6 +3047,8 @@ def test_client_to_server(base_dir: str):
print(">>> s2s post arrived in Bob's inbox") print(">>> s2s post arrived in Bob's inbox")
time.sleep(2)
calendar_path = bob_dir + '/accounts/bob@' + bob_domain + '/calendar' calendar_path = bob_dir + '/accounts/bob@' + bob_domain + '/calendar'
if not os.path.isdir(calendar_path): if not os.path.isdir(calendar_path):
print('Missing calendar path: ' + calendar_path) print('Missing calendar path: ' + calendar_path)
@ -6744,4 +6746,5 @@ def run_all_tests():
_test_followers_on_domain(base_dir) _test_followers_on_domain(base_dir)
_test_follows(base_dir) _test_follows(base_dir)
_test_group_followers(base_dir) _test_group_followers(base_dir)
time.sleep(2)
print('Tests succeeded\n') print('Tests succeeded\n')

View File

@ -1887,7 +1887,7 @@ def _get_reserved_words() -> str:
'tlblogs', 'tlfeatures', 'tlblogs', 'tlfeatures',
'moderation', 'moderationaction', 'moderation', 'moderationaction',
'activity', 'undo', 'pinned', 'activity', 'undo', 'pinned',
'actor', 'Actor', 'actor', 'Actor', 'instance.actor',
'reply', 'replies', 'question', 'like', 'reply', 'replies', 'question', 'like',
'likes', 'users', 'statuses', 'tags', 'likes', 'users', 'statuses', 'tags',
'accounts', 'headers', 'accounts', 'headers',