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

merge-requests/30/head
Bob Mottram 2022-02-28 13:50:25 +00:00
commit f495647f39
6 changed files with 59 additions and 37 deletions

View File

@ -1991,7 +1991,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.postreq_busy = False
return
# login success - redirect with authorization
print('Login success: ' + login_nickname)
print('====== Login success: ' + login_nickname)
# re-activate account if needed
activate_account(base_dir, login_nickname, domain)
# This produces a deterministic token based

View File

@ -1744,7 +1744,7 @@ div.container {
font-family: 'NimbusSanL';
opacity: 0.7;
}
input[type=checkbox]
input[type=checkbox], .profilecheckbox
{
-ms-transform: scale(2);
-moz-transform: scale(2);
@ -2486,13 +2486,13 @@ div.container {
font-family: 'NimbusSanL';
opacity: 0.7;
}
input[type=checkbox]
input[type=checkbox], .profilecheckbox
{
-ms-transform: scale(4);
-moz-transform: scale(4);
-webkit-transform: scale(4);
-o-transform: scale(4);
transform: scale(4);
-ms-transform: scale(2);
-moz-transform: scale(2);
-webkit-transform: scale(2);
-o-transform: scale(2);
transform: scale(2);
padding: 20px;
margin: 30px 40px;
}
@ -3225,13 +3225,13 @@ div.container {
font-family: 'NimbusSanL';
opacity: 0.7;
}
input[type=checkbox]
input[type=checkbox], .profilecheckbox
{
-ms-transform: scale(4);
-moz-transform: scale(4);
-webkit-transform: scale(4);
-o-transform: scale(4);
transform: scale(4);
-ms-transform: scale(2);
-moz-transform: scale(2);
-webkit-transform: scale(2);
-o-transform: scale(2);
transform: scale(2);
padding: 20px;
margin: 30px 40px;
width: 10px;

View File

@ -86,8 +86,10 @@ def replace_twitter(post_json_object: {}, replacement_domain: str,
"""Replace Twitter with a replacement domain
This allows you to view twitter posts without having a twitter account
"""
_replace_silo_domain(post_json_object, 'twitter.com',
replacement_domain, system_language)
twitter_domains = ('mobile.twitter.com', 'twitter.com')
for tw_domain in twitter_domains:
_replace_silo_domain(post_json_object, tw_domain,
replacement_domain, system_language)
def _remove_meta_data(image_filename: str, output_filename: str) -> None:

View File

@ -2262,7 +2262,8 @@ def thread_send_post(session, post_json_str: str, federation_list: [],
inbox_url: str, base_dir: str,
signature_header_json: {},
signature_header_json_ld: {},
post_log: [], debug: bool) -> None:
post_log: [], debug: bool,
http_prefix: str, domain_full: str) -> None:
"""Sends a with retries
"""
tries = 0
@ -2276,7 +2277,7 @@ def thread_send_post(session, post_json_str: str, federation_list: [],
post_result, unauthorized, return_code = \
post_json_string(session, post_json_str, federation_list,
inbox_url, signature_header_json,
debug)
debug, http_prefix, domain_full)
if return_code >= 500 and return_code < 600:
# if an instance is returning a code which indicates that
# it might have a runtime error, like 503, then don't
@ -2298,7 +2299,7 @@ def thread_send_post(session, post_json_str: str, federation_list: [],
post_result, unauthorized, return_code = \
post_json_string(session, post_json_str, federation_list,
inbox_url, signature_header_json_ld,
debug)
debug, http_prefix, domain_full)
if return_code >= 500 and return_code < 600:
# if an instance is returning a code which indicates that
# it might have a runtime error, like 503, then don't
@ -2467,12 +2468,15 @@ def send_post(signing_priv_key_pem: str, project_version: str,
# if the "to" domain is within the shared items
# federation list then send the token for this domain
# so that it can request a catalog
domain_full = get_full_domain(domain, port)
if to_domain in shared_items_federated_domains:
domain_full = get_full_domain(domain, port)
if shared_item_federation_tokens.get(domain_full):
signature_header_json['Origin'] = domain_full
signature_header_json_ld['Origin'] = domain_full
signature_header_json['SharesCatalog'] = \
shared_item_federation_tokens[domain_full]
signature_header_json_ld['SharesCatalog'] = \
shared_item_federation_tokens[domain_full]
if debug:
print('SharesCatalog added to header')
elif debug:
@ -2498,8 +2502,8 @@ def send_post(signing_priv_key_pem: str, project_version: str,
inbox_url, base_dir,
signature_header_json.copy(),
signature_header_json_ld.copy(),
post_log,
debug), daemon=True)
post_log, debug, http_prefix,
domain_full), daemon=True)
send_threads.append(thr)
thr.start()
return 0
@ -2622,7 +2626,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
}
post_result = \
post_image(session, attach_image_filename, [],
inbox_url, headers)
inbox_url, headers, http_prefix, from_domain_full)
if not post_result:
if debug:
print('DEBUG: post failed to upload image')
@ -2636,7 +2640,9 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
post_dumps = json.dumps(post_json_object)
post_result, unauthorized, return_code = \
post_json_string(session, post_dumps, [],
inbox_url, headers, debug, 5, True)
inbox_url, headers, debug,
http_prefix, from_domain_full,
5, True)
if not post_result:
if debug:
if unauthorized:
@ -2874,6 +2880,7 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
if debug:
print('DEBUG: starting thread to send post')
pprint(post_json_object)
domain_full = get_full_domain(domain, port)
thr = \
thread_with_trace(target=thread_send_post,
args=(session,
@ -2882,8 +2889,8 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
inbox_url, base_dir,
signature_header_json.copy(),
signature_header_json_ld.copy(),
post_log,
debug), daemon=True)
post_log, debug,
http_prefix, domain_full), daemon=True)
send_threads.append(thr)
# thr.start()
return 0

View File

@ -367,6 +367,15 @@ def download_html(signing_priv_key_pem: str,
None, quiet, debug, False)
def _set_user_agent(session, http_prefix: str, domain_full: str) -> None:
"""Sets the user agent
"""
ua_str = \
'Epicyon/' + __version__ + '; +' + \
http_prefix + '://' + domain_full + '/'
session.headers.update({'User-Agent': ua_str})
def post_json(http_prefix: str, domain_full: str,
session, post_json_object: {}, federation_list: [],
inbox_url: str, headers: {}, timeout_sec: int = 60,
@ -379,10 +388,7 @@ def post_json(http_prefix: str, domain_full: str,
print('post_json: ' + inbox_url + ' not permitted')
return None
session_headers = headers
session_headers['User-Agent'] = 'Epicyon/' + __version__
session_headers['User-Agent'] += \
'; +' + http_prefix + '://' + domain_full + '/'
_set_user_agent(session, http_prefix, domain_full)
try:
post_result = \
@ -421,6 +427,7 @@ def post_json_string(session, post_jsonStr: str,
inbox_url: str,
headers: {},
debug: bool,
http_prefix: str, domain_full: str,
timeout_sec: int = 30,
quiet: bool = False) -> (bool, bool, int):
"""Post a json message string to the inbox of another person
@ -435,6 +442,8 @@ def post_json_string(session, post_jsonStr: str,
print('post_json_string: ' + inbox_url + ' not permitted')
return False, True, 0
_set_user_agent(session, http_prefix, domain_full)
try:
post_result = \
session.post(url=inbox_url, data=post_jsonStr,
@ -473,7 +482,8 @@ def post_json_string(session, post_jsonStr: str,
def post_image(session, attach_image_filename: str, federation_list: [],
inbox_url: str, headers: {}) -> str:
inbox_url: str, headers: {},
http_prefix: str, domain_full: str) -> str:
"""Post an image to the inbox of another person or outbox via c2s
"""
# check that we are posting to a permitted domain
@ -504,6 +514,9 @@ def post_image(session, attach_image_filename: str, federation_list: [],
with open(attach_image_filename, 'rb') as av_file:
media_binary = av_file.read()
_set_user_agent(session, http_prefix, domain_full)
try:
post_result = session.post(url=inbox_url, data=media_binary,
headers=headers)

View File

@ -653,10 +653,10 @@ def send_share_via_server(base_dir, session,
'host': from_domain,
'Authorization': auth_header
}
inbox_url_str = inbox_url.replace('/' + post_to_box, '/shares')
post_result = \
post_image(session, image_filename, [],
inbox_url.replace('/' + post_to_box, '/shares'),
headers)
post_image(session, image_filename, [], inbox_url_str,
headers, http_prefix, from_domain_full)
headers = {
'host': from_domain,
@ -873,10 +873,10 @@ def send_wanted_via_server(base_dir, session,
'host': from_domain,
'Authorization': auth_header
}
inbox_url_str = inbox_url.replace('/' + post_to_box, '/wanted')
post_result = \
post_image(session, image_filename, [],
inbox_url.replace('/' + post_to_box, '/wanted'),
headers)
post_image(session, image_filename, [], inbox_url_str,
headers, http_prefix, from_domain_full)
headers = {
'host': from_domain,