mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
cf351a2fd4
commit
b4120ce638
|
@ -14,6 +14,7 @@ from httpcodes import http_404
|
||||||
from httpcodes import write2
|
from httpcodes import write2
|
||||||
from httpheaders import set_headers_etag
|
from httpheaders import set_headers_etag
|
||||||
from httpheaders import set_headers
|
from httpheaders import set_headers
|
||||||
|
from utils import string_ends_with
|
||||||
from utils import get_css
|
from utils import get_css
|
||||||
from fitnessFunctions import fitness_performance
|
from fitnessFunctions import fitness_performance
|
||||||
from daemon_utils import etag_exists
|
from daemon_utils import etag_exists
|
||||||
|
@ -69,10 +70,8 @@ def get_fonts(self, calling_domain: str, path: str,
|
||||||
"""Returns a font
|
"""Returns a font
|
||||||
"""
|
"""
|
||||||
font_str = path.split('/fonts/')[1]
|
font_str = path.split('/fonts/')[1]
|
||||||
if font_str.endswith('.otf') or \
|
possible_extensions = ('.otf', '.ttf', '.woff', '.woff2')
|
||||||
font_str.endswith('.ttf') or \
|
if string_ends_with(font_str, possible_extensions):
|
||||||
font_str.endswith('.woff') or \
|
|
||||||
font_str.endswith('.woff2'):
|
|
||||||
if font_str.endswith('.otf'):
|
if font_str.endswith('.otf'):
|
||||||
font_type = 'font/otf'
|
font_type = 'font/otf'
|
||||||
elif font_str.endswith('.ttf'):
|
elif font_str.endswith('.ttf'):
|
||||||
|
|
|
@ -11,6 +11,7 @@ import time
|
||||||
import errno
|
import errno
|
||||||
import json
|
import json
|
||||||
from socket import error as SocketError
|
from socket import error as SocketError
|
||||||
|
from utils import string_ends_with
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import decoded_host
|
from utils import decoded_host
|
||||||
from utils import get_new_post_endpoints
|
from utils import get_new_post_endpoints
|
||||||
|
@ -705,9 +706,8 @@ def daemon_http_post(self) -> None:
|
||||||
'_POST', 'receive post',
|
'_POST', 'receive post',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
if self.path.endswith('/outbox') or \
|
possible_path_endings = ('/outbox', '/wanted', '/shares')
|
||||||
self.path.endswith('/wanted') or \
|
if string_ends_with(self.path, possible_path_endings):
|
||||||
self.path.endswith('/shares'):
|
|
||||||
if users_in_path:
|
if users_in_path:
|
||||||
if authorized:
|
if authorized:
|
||||||
self.outbox_authenticated = True
|
self.outbox_authenticated = True
|
||||||
|
@ -724,12 +724,10 @@ def daemon_http_post(self) -> None:
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
# check that the post is to an expected path
|
# check that the post is to an expected path
|
||||||
if not (self.path.endswith('/outbox') or
|
possible_endings = ('/outbox', '/inbox', '/wanted', '/shares',
|
||||||
self.path.endswith('/inbox') or
|
'/moderationaction')
|
||||||
self.path.endswith('/wanted') or
|
if not string_ends_with(self.path, possible_endings) and \
|
||||||
self.path.endswith('/shares') or
|
self.path != '/sharedInbox':
|
||||||
self.path.endswith('/moderationaction') or
|
|
||||||
self.path == '/sharedInbox'):
|
|
||||||
print('Attempt to POST to invalid path ' + self.path)
|
print('Attempt to POST to invalid path ' + self.path)
|
||||||
http_400(self)
|
http_400(self)
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
|
|
|
@ -14,6 +14,7 @@ from utils import get_instance_url
|
||||||
from httpcodes import write2
|
from httpcodes import write2
|
||||||
from httpheaders import login_headers
|
from httpheaders import login_headers
|
||||||
from httpheaders import redirect_headers
|
from httpheaders import redirect_headers
|
||||||
|
from utils import string_ends_with
|
||||||
from utils import has_users_path
|
from utils import has_users_path
|
||||||
from utils import get_nickname_from_actor
|
from utils import get_nickname_from_actor
|
||||||
from utils import get_domain_from_actor
|
from utils import get_domain_from_actor
|
||||||
|
@ -100,6 +101,10 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
||||||
print('search_str: ' + search_str)
|
print('search_str: ' + search_str)
|
||||||
if search_for_emoji:
|
if search_for_emoji:
|
||||||
search_str = ':' + search_str + ':'
|
search_str = ':' + search_str + ':'
|
||||||
|
my_posts_endings = (
|
||||||
|
' history', ' in sent', ' in outbox', ' in outgoing',
|
||||||
|
' in sent items', ' in sent posts', ' in outgoing posts',
|
||||||
|
' in my history', ' in my outbox', ' in my posts')
|
||||||
if search_str.startswith('#'):
|
if search_str.startswith('#'):
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
|
@ -186,16 +191,8 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
elif (search_str.startswith("'") or
|
elif (search_str.startswith("'") or
|
||||||
search_str.endswith(' history') or
|
string_ends_with(search_str, my_posts_endings)):
|
||||||
search_str.endswith(' in sent') or
|
# your post history search
|
||||||
search_str.endswith(' in outbox') or
|
|
||||||
search_str.endswith(' in outgoing') or
|
|
||||||
search_str.endswith(' in sent items') or
|
|
||||||
search_str.endswith(' in sent posts') or
|
|
||||||
search_str.endswith(' in outgoing posts') or
|
|
||||||
search_str.endswith(' in my history') or
|
|
||||||
search_str.endswith(' in my outbox') or
|
|
||||||
search_str.endswith(' in my posts')):
|
|
||||||
possible_endings = (
|
possible_endings = (
|
||||||
' in my posts',
|
' in my posts',
|
||||||
' in my history',
|
' in my history',
|
||||||
|
@ -213,7 +210,6 @@ def receive_search_query(self, calling_domain: str, cookie: str,
|
||||||
if search_str.endswith(poss_ending):
|
if search_str.endswith(poss_ending):
|
||||||
search_str = search_str.replace(poss_ending, '')
|
search_str = search_str.replace(poss_ending, '')
|
||||||
break
|
break
|
||||||
# your post history search
|
|
||||||
nickname = get_nickname_from_actor(actor_str)
|
nickname = get_nickname_from_actor(actor_str)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
self.send_response(400)
|
self.send_response(400)
|
||||||
|
|
Loading…
Reference in New Issue