mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
f495647f39
|
@ -1991,7 +1991,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.postreq_busy = False
|
self.server.postreq_busy = False
|
||||||
return
|
return
|
||||||
# login success - redirect with authorization
|
# login success - redirect with authorization
|
||||||
print('Login success: ' + login_nickname)
|
print('====== Login success: ' + login_nickname)
|
||||||
# re-activate account if needed
|
# re-activate account if needed
|
||||||
activate_account(base_dir, login_nickname, domain)
|
activate_account(base_dir, login_nickname, domain)
|
||||||
# This produces a deterministic token based
|
# This produces a deterministic token based
|
||||||
|
|
|
@ -1744,7 +1744,7 @@ div.container {
|
||||||
font-family: 'NimbusSanL';
|
font-family: 'NimbusSanL';
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
input[type=checkbox]
|
input[type=checkbox], .profilecheckbox
|
||||||
{
|
{
|
||||||
-ms-transform: scale(2);
|
-ms-transform: scale(2);
|
||||||
-moz-transform: scale(2);
|
-moz-transform: scale(2);
|
||||||
|
@ -2486,13 +2486,13 @@ div.container {
|
||||||
font-family: 'NimbusSanL';
|
font-family: 'NimbusSanL';
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
input[type=checkbox]
|
input[type=checkbox], .profilecheckbox
|
||||||
{
|
{
|
||||||
-ms-transform: scale(4);
|
-ms-transform: scale(2);
|
||||||
-moz-transform: scale(4);
|
-moz-transform: scale(2);
|
||||||
-webkit-transform: scale(4);
|
-webkit-transform: scale(2);
|
||||||
-o-transform: scale(4);
|
-o-transform: scale(2);
|
||||||
transform: scale(4);
|
transform: scale(2);
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
margin: 30px 40px;
|
margin: 30px 40px;
|
||||||
}
|
}
|
||||||
|
@ -3225,13 +3225,13 @@ div.container {
|
||||||
font-family: 'NimbusSanL';
|
font-family: 'NimbusSanL';
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
input[type=checkbox]
|
input[type=checkbox], .profilecheckbox
|
||||||
{
|
{
|
||||||
-ms-transform: scale(4);
|
-ms-transform: scale(2);
|
||||||
-moz-transform: scale(4);
|
-moz-transform: scale(2);
|
||||||
-webkit-transform: scale(4);
|
-webkit-transform: scale(2);
|
||||||
-o-transform: scale(4);
|
-o-transform: scale(2);
|
||||||
transform: scale(4);
|
transform: scale(2);
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
margin: 30px 40px;
|
margin: 30px 40px;
|
||||||
width: 10px;
|
width: 10px;
|
||||||
|
|
6
media.py
6
media.py
|
@ -86,8 +86,10 @@ def replace_twitter(post_json_object: {}, replacement_domain: str,
|
||||||
"""Replace Twitter with a replacement domain
|
"""Replace Twitter with a replacement domain
|
||||||
This allows you to view twitter posts without having a twitter account
|
This allows you to view twitter posts without having a twitter account
|
||||||
"""
|
"""
|
||||||
_replace_silo_domain(post_json_object, 'twitter.com',
|
twitter_domains = ('mobile.twitter.com', 'twitter.com')
|
||||||
replacement_domain, system_language)
|
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:
|
def _remove_meta_data(image_filename: str, output_filename: str) -> None:
|
||||||
|
|
27
posts.py
27
posts.py
|
@ -2262,7 +2262,8 @@ def thread_send_post(session, post_json_str: str, federation_list: [],
|
||||||
inbox_url: str, base_dir: str,
|
inbox_url: str, base_dir: str,
|
||||||
signature_header_json: {},
|
signature_header_json: {},
|
||||||
signature_header_json_ld: {},
|
signature_header_json_ld: {},
|
||||||
post_log: [], debug: bool) -> None:
|
post_log: [], debug: bool,
|
||||||
|
http_prefix: str, domain_full: str) -> None:
|
||||||
"""Sends a with retries
|
"""Sends a with retries
|
||||||
"""
|
"""
|
||||||
tries = 0
|
tries = 0
|
||||||
|
@ -2276,7 +2277,7 @@ def thread_send_post(session, post_json_str: str, federation_list: [],
|
||||||
post_result, unauthorized, return_code = \
|
post_result, unauthorized, return_code = \
|
||||||
post_json_string(session, post_json_str, federation_list,
|
post_json_string(session, post_json_str, federation_list,
|
||||||
inbox_url, signature_header_json,
|
inbox_url, signature_header_json,
|
||||||
debug)
|
debug, http_prefix, domain_full)
|
||||||
if return_code >= 500 and return_code < 600:
|
if return_code >= 500 and return_code < 600:
|
||||||
# if an instance is returning a code which indicates that
|
# if an instance is returning a code which indicates that
|
||||||
# it might have a runtime error, like 503, then don't
|
# 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_result, unauthorized, return_code = \
|
||||||
post_json_string(session, post_json_str, federation_list,
|
post_json_string(session, post_json_str, federation_list,
|
||||||
inbox_url, signature_header_json_ld,
|
inbox_url, signature_header_json_ld,
|
||||||
debug)
|
debug, http_prefix, domain_full)
|
||||||
if return_code >= 500 and return_code < 600:
|
if return_code >= 500 and return_code < 600:
|
||||||
# if an instance is returning a code which indicates that
|
# if an instance is returning a code which indicates that
|
||||||
# it might have a runtime error, like 503, then don't
|
# 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
|
# if the "to" domain is within the shared items
|
||||||
# federation list then send the token for this domain
|
# federation list then send the token for this domain
|
||||||
# so that it can request a catalog
|
# so that it can request a catalog
|
||||||
|
domain_full = get_full_domain(domain, port)
|
||||||
if to_domain in shared_items_federated_domains:
|
if to_domain in shared_items_federated_domains:
|
||||||
domain_full = get_full_domain(domain, port)
|
|
||||||
if shared_item_federation_tokens.get(domain_full):
|
if shared_item_federation_tokens.get(domain_full):
|
||||||
signature_header_json['Origin'] = domain_full
|
signature_header_json['Origin'] = domain_full
|
||||||
|
signature_header_json_ld['Origin'] = domain_full
|
||||||
signature_header_json['SharesCatalog'] = \
|
signature_header_json['SharesCatalog'] = \
|
||||||
shared_item_federation_tokens[domain_full]
|
shared_item_federation_tokens[domain_full]
|
||||||
|
signature_header_json_ld['SharesCatalog'] = \
|
||||||
|
shared_item_federation_tokens[domain_full]
|
||||||
if debug:
|
if debug:
|
||||||
print('SharesCatalog added to header')
|
print('SharesCatalog added to header')
|
||||||
elif debug:
|
elif debug:
|
||||||
|
@ -2498,8 +2502,8 @@ def send_post(signing_priv_key_pem: str, project_version: str,
|
||||||
inbox_url, base_dir,
|
inbox_url, base_dir,
|
||||||
signature_header_json.copy(),
|
signature_header_json.copy(),
|
||||||
signature_header_json_ld.copy(),
|
signature_header_json_ld.copy(),
|
||||||
post_log,
|
post_log, debug, http_prefix,
|
||||||
debug), daemon=True)
|
domain_full), daemon=True)
|
||||||
send_threads.append(thr)
|
send_threads.append(thr)
|
||||||
thr.start()
|
thr.start()
|
||||||
return 0
|
return 0
|
||||||
|
@ -2622,7 +2626,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
||||||
}
|
}
|
||||||
post_result = \
|
post_result = \
|
||||||
post_image(session, attach_image_filename, [],
|
post_image(session, attach_image_filename, [],
|
||||||
inbox_url, headers)
|
inbox_url, headers, http_prefix, from_domain_full)
|
||||||
if not post_result:
|
if not post_result:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post failed to upload image')
|
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_dumps = json.dumps(post_json_object)
|
||||||
post_result, unauthorized, return_code = \
|
post_result, unauthorized, return_code = \
|
||||||
post_json_string(session, post_dumps, [],
|
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 not post_result:
|
||||||
if debug:
|
if debug:
|
||||||
if unauthorized:
|
if unauthorized:
|
||||||
|
@ -2874,6 +2880,7 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: starting thread to send post')
|
print('DEBUG: starting thread to send post')
|
||||||
pprint(post_json_object)
|
pprint(post_json_object)
|
||||||
|
domain_full = get_full_domain(domain, port)
|
||||||
thr = \
|
thr = \
|
||||||
thread_with_trace(target=thread_send_post,
|
thread_with_trace(target=thread_send_post,
|
||||||
args=(session,
|
args=(session,
|
||||||
|
@ -2882,8 +2889,8 @@ def send_signed_json(post_json_object: {}, session, base_dir: str,
|
||||||
inbox_url, base_dir,
|
inbox_url, base_dir,
|
||||||
signature_header_json.copy(),
|
signature_header_json.copy(),
|
||||||
signature_header_json_ld.copy(),
|
signature_header_json_ld.copy(),
|
||||||
post_log,
|
post_log, debug,
|
||||||
debug), daemon=True)
|
http_prefix, domain_full), daemon=True)
|
||||||
send_threads.append(thr)
|
send_threads.append(thr)
|
||||||
# thr.start()
|
# thr.start()
|
||||||
return 0
|
return 0
|
||||||
|
|
23
session.py
23
session.py
|
@ -367,6 +367,15 @@ def download_html(signing_priv_key_pem: str,
|
||||||
None, quiet, debug, False)
|
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,
|
def post_json(http_prefix: str, domain_full: str,
|
||||||
session, post_json_object: {}, federation_list: [],
|
session, post_json_object: {}, federation_list: [],
|
||||||
inbox_url: str, headers: {}, timeout_sec: int = 60,
|
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')
|
print('post_json: ' + inbox_url + ' not permitted')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
session_headers = headers
|
_set_user_agent(session, http_prefix, domain_full)
|
||||||
session_headers['User-Agent'] = 'Epicyon/' + __version__
|
|
||||||
session_headers['User-Agent'] += \
|
|
||||||
'; +' + http_prefix + '://' + domain_full + '/'
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
post_result = \
|
post_result = \
|
||||||
|
@ -421,6 +427,7 @@ def post_json_string(session, post_jsonStr: str,
|
||||||
inbox_url: str,
|
inbox_url: str,
|
||||||
headers: {},
|
headers: {},
|
||||||
debug: bool,
|
debug: bool,
|
||||||
|
http_prefix: str, domain_full: str,
|
||||||
timeout_sec: int = 30,
|
timeout_sec: int = 30,
|
||||||
quiet: bool = False) -> (bool, bool, int):
|
quiet: bool = False) -> (bool, bool, int):
|
||||||
"""Post a json message string to the inbox of another person
|
"""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')
|
print('post_json_string: ' + inbox_url + ' not permitted')
|
||||||
return False, True, 0
|
return False, True, 0
|
||||||
|
|
||||||
|
_set_user_agent(session, http_prefix, domain_full)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
post_result = \
|
post_result = \
|
||||||
session.post(url=inbox_url, data=post_jsonStr,
|
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: [],
|
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
|
"""Post an image to the inbox of another person or outbox via c2s
|
||||||
"""
|
"""
|
||||||
# check that we are posting to a permitted domain
|
# 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:
|
with open(attach_image_filename, 'rb') as av_file:
|
||||||
media_binary = av_file.read()
|
media_binary = av_file.read()
|
||||||
|
|
||||||
|
_set_user_agent(session, http_prefix, domain_full)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
post_result = session.post(url=inbox_url, data=media_binary,
|
post_result = session.post(url=inbox_url, data=media_binary,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
12
shares.py
12
shares.py
|
@ -653,10 +653,10 @@ def send_share_via_server(base_dir, session,
|
||||||
'host': from_domain,
|
'host': from_domain,
|
||||||
'Authorization': auth_header
|
'Authorization': auth_header
|
||||||
}
|
}
|
||||||
|
inbox_url_str = inbox_url.replace('/' + post_to_box, '/shares')
|
||||||
post_result = \
|
post_result = \
|
||||||
post_image(session, image_filename, [],
|
post_image(session, image_filename, [], inbox_url_str,
|
||||||
inbox_url.replace('/' + post_to_box, '/shares'),
|
headers, http_prefix, from_domain_full)
|
||||||
headers)
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'host': from_domain,
|
'host': from_domain,
|
||||||
|
@ -873,10 +873,10 @@ def send_wanted_via_server(base_dir, session,
|
||||||
'host': from_domain,
|
'host': from_domain,
|
||||||
'Authorization': auth_header
|
'Authorization': auth_header
|
||||||
}
|
}
|
||||||
|
inbox_url_str = inbox_url.replace('/' + post_to_box, '/wanted')
|
||||||
post_result = \
|
post_result = \
|
||||||
post_image(session, image_filename, [],
|
post_image(session, image_filename, [], inbox_url_str,
|
||||||
inbox_url.replace('/' + post_to_box, '/wanted'),
|
headers, http_prefix, from_domain_full)
|
||||||
headers)
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'host': from_domain,
|
'host': from_domain,
|
||||||
|
|
Loading…
Reference in New Issue