mirror of https://gitlab.com/bashrc2/epicyon
More debug conditions
parent
fc4626bb51
commit
bbb9881b54
|
|
@ -282,7 +282,8 @@ def _accept_follow(base_dir: str, message_json: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: receiving Follow activity')
|
print('DEBUG: receiving Follow activity')
|
||||||
if not message_json['object'].get('actor'):
|
if not message_json['object'].get('actor'):
|
||||||
print('DEBUG: no actor in Follow activity')
|
if debug:
|
||||||
|
print('DEBUG: no actor in Follow activity')
|
||||||
return
|
return
|
||||||
# no, this isn't a mistake
|
# no, this isn't a mistake
|
||||||
if not has_object_string_object(message_json, debug):
|
if not has_object_string_object(message_json, debug):
|
||||||
|
|
@ -296,7 +297,8 @@ def _accept_follow(base_dir: str, message_json: {},
|
||||||
this_actor = get_actor_from_post(message_json['object'])
|
this_actor = get_actor_from_post(message_json['object'])
|
||||||
nickname = get_nickname_from_actor(this_actor)
|
nickname = get_nickname_from_actor(this_actor)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: no nickname found in ' + this_actor)
|
if debug:
|
||||||
|
print('WARN: no nickname found in ' + this_actor)
|
||||||
return
|
return
|
||||||
accepted_domain, accepted_port = get_domain_from_actor(this_actor)
|
accepted_domain, accepted_port = get_domain_from_actor(this_actor)
|
||||||
if not accepted_domain:
|
if not accepted_domain:
|
||||||
|
|
|
||||||
34
announce.py
34
announce.py
|
|
@ -108,11 +108,13 @@ def outbox_announce(recent_posts_cache: {},
|
||||||
actor_url = get_actor_from_post(message_json)
|
actor_url = get_actor_from_post(message_json)
|
||||||
nickname = get_nickname_from_actor(actor_url)
|
nickname = get_nickname_from_actor(actor_url)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: no nickname found in ' + actor_url)
|
if debug:
|
||||||
|
print('WARN: no nickname found in ' + actor_url)
|
||||||
return False
|
return False
|
||||||
domain, _ = get_domain_from_actor(actor_url)
|
domain, _ = get_domain_from_actor(actor_url)
|
||||||
if not domain:
|
if not domain:
|
||||||
print('WARN: no domain found in ' + actor_url)
|
if debug:
|
||||||
|
print('WARN: no domain found in ' + actor_url)
|
||||||
return False
|
return False
|
||||||
post_filename = locate_post(base_dir, nickname, domain,
|
post_filename = locate_post(base_dir, nickname, domain,
|
||||||
message_json['object'])
|
message_json['object'])
|
||||||
|
|
@ -131,11 +133,13 @@ def outbox_announce(recent_posts_cache: {},
|
||||||
actor_url = get_actor_from_post(message_json)
|
actor_url = get_actor_from_post(message_json)
|
||||||
nickname = get_nickname_from_actor(actor_url)
|
nickname = get_nickname_from_actor(actor_url)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: no nickname found in ' + actor_url)
|
if debug:
|
||||||
|
print('WARN: no nickname found in ' + actor_url)
|
||||||
return False
|
return False
|
||||||
domain, _ = get_domain_from_actor(actor_url)
|
domain, _ = get_domain_from_actor(actor_url)
|
||||||
if not domain:
|
if not domain:
|
||||||
print('WARN: no domain found in ' + actor_url)
|
if debug:
|
||||||
|
print('WARN: no domain found in ' + actor_url)
|
||||||
return False
|
return False
|
||||||
post_filename = locate_post(base_dir, nickname, domain,
|
post_filename = locate_post(base_dir, nickname, domain,
|
||||||
message_json['object']['object'])
|
message_json['object']['object'])
|
||||||
|
|
@ -294,7 +298,8 @@ def send_announce_via_server(base_dir: str, session,
|
||||||
"""Creates an announce message via c2s
|
"""Creates an announce message via c2s
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for send_announce_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for send_announce_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
from_domain_full = get_full_domain(from_domain, from_port)
|
from_domain_full = get_full_domain(from_domain, from_port)
|
||||||
|
|
@ -332,8 +337,9 @@ def send_announce_via_server(base_dir: str, session,
|
||||||
print('DEBUG: announce webfinger failed for ' + handle)
|
print('DEBUG: announce webfinger failed for ' + handle)
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wf_request, dict):
|
if not isinstance(wf_request, dict):
|
||||||
print('WARN: announce webfinger for ' + handle +
|
if debug:
|
||||||
' did not return a dict. ' + str(wf_request))
|
print('WARN: announce webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wf_request))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
post_to_box: str = 'outbox'
|
post_to_box: str = 'outbox'
|
||||||
|
|
@ -371,7 +377,8 @@ def send_announce_via_server(base_dir: str, session,
|
||||||
session, new_announce_json, [], inbox_url,
|
session, new_announce_json, [], inbox_url,
|
||||||
headers, 3, True)
|
headers, 3, True)
|
||||||
if not post_result:
|
if not post_result:
|
||||||
print('WARN: announce not posted')
|
if debug:
|
||||||
|
print('WARN: announce not posted')
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s POST announce success')
|
print('DEBUG: c2s POST announce success')
|
||||||
|
|
@ -391,7 +398,8 @@ def send_undo_announce_via_server(base_dir: str, session,
|
||||||
"""Undo an announce message via c2s
|
"""Undo an announce message via c2s
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for send_undo_announce_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for send_undo_announce_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
|
@ -421,8 +429,9 @@ def send_undo_announce_via_server(base_dir: str, session,
|
||||||
print('DEBUG: undo announce webfinger failed for ' + handle)
|
print('DEBUG: undo announce webfinger failed for ' + handle)
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wf_request, dict):
|
if not isinstance(wf_request, dict):
|
||||||
print('WARN: undo announce webfinger for ' + handle +
|
if debug:
|
||||||
' did not return a dict. ' + str(wf_request))
|
print('WARN: undo announce webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wf_request))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
post_to_box: str = 'outbox'
|
post_to_box: str = 'outbox'
|
||||||
|
|
@ -460,7 +469,8 @@ def send_undo_announce_via_server(base_dir: str, session,
|
||||||
session, unannounce_json, [], inbox_url,
|
session, unannounce_json, [], inbox_url,
|
||||||
headers, 3, True)
|
headers, 3, True)
|
||||||
if not post_result:
|
if not post_result:
|
||||||
print('WARN: undo announce not posted')
|
if debug:
|
||||||
|
print('WARN: undo announce not posted')
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s POST undo announce success')
|
print('DEBUG: c2s POST undo announce success')
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,8 @@ def send_availability_via_server(base_dir: str, session,
|
||||||
"""Sets the availability for a person via c2s
|
"""Sets the availability for a person via c2s
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for send_availability_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for send_availability_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
|
@ -140,8 +141,9 @@ def send_availability_via_server(base_dir: str, session,
|
||||||
print('DEBUG: availability webfinger failed for ' + handle)
|
print('DEBUG: availability webfinger failed for ' + handle)
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wf_request, dict):
|
if not isinstance(wf_request, dict):
|
||||||
print('WARN: availability webfinger for ' + handle +
|
if debug:
|
||||||
' did not return a dict. ' + str(wf_request))
|
print('WARN: availability webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wf_request))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
post_to_box: str = 'outbox'
|
post_to_box: str = 'outbox'
|
||||||
|
|
@ -178,7 +180,8 @@ def send_availability_via_server(base_dir: str, session,
|
||||||
session, new_availability_json, [],
|
session, new_availability_json, [],
|
||||||
inbox_url, headers, 30, True)
|
inbox_url, headers, 30, True)
|
||||||
if not post_result:
|
if not post_result:
|
||||||
print('WARN: availability failed to post')
|
if debug:
|
||||||
|
print('WARN: availability failed to post')
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s POST availability success')
|
print('DEBUG: c2s POST availability success')
|
||||||
|
|
|
||||||
38
blocking.py
38
blocking.py
|
|
@ -1160,14 +1160,16 @@ def outbox_block(base_dir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
nickname_blocked = get_nickname_from_actor(message_json['object'])
|
nickname_blocked = get_nickname_from_actor(message_json['object'])
|
||||||
if not nickname_blocked:
|
if not nickname_blocked:
|
||||||
print('WARN: outbox_block unable to find nickname in ' +
|
if debug:
|
||||||
message_json['object'])
|
print('WARN: outbox_block unable to find nickname in ' +
|
||||||
|
message_json['object'])
|
||||||
return False
|
return False
|
||||||
domain_blocked, port_blocked = \
|
domain_blocked, port_blocked = \
|
||||||
get_domain_from_actor(message_json['object'])
|
get_domain_from_actor(message_json['object'])
|
||||||
if not domain_blocked:
|
if not domain_blocked:
|
||||||
print('WARN: outbox_block unable to find domain in ' +
|
if debug:
|
||||||
message_json['object'])
|
print('WARN: outbox_block unable to find domain in ' +
|
||||||
|
message_json['object'])
|
||||||
return False
|
return False
|
||||||
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
||||||
|
|
||||||
|
|
@ -1222,14 +1224,16 @@ def outbox_undo_block(base_dir: str, nickname: str, domain: str,
|
||||||
nickname_blocked = \
|
nickname_blocked = \
|
||||||
get_nickname_from_actor(message_json['object']['object'])
|
get_nickname_from_actor(message_json['object']['object'])
|
||||||
if not nickname_blocked:
|
if not nickname_blocked:
|
||||||
print('WARN: outbox_undo_block unable to find nickname in ' +
|
if debug:
|
||||||
message_json['object']['object'])
|
print('WARN: outbox_undo_block unable to find nickname in ' +
|
||||||
|
message_json['object']['object'])
|
||||||
return
|
return
|
||||||
domain_object = message_json['object']['object']
|
domain_object = message_json['object']['object']
|
||||||
domain_blocked, port_blocked = get_domain_from_actor(domain_object)
|
domain_blocked, port_blocked = get_domain_from_actor(domain_object)
|
||||||
if not domain_blocked:
|
if not domain_blocked:
|
||||||
print('WARN: outbox_undo_block unable to find domain in ' +
|
if debug:
|
||||||
message_json['object']['object'])
|
print('WARN: outbox_undo_block unable to find domain in ' +
|
||||||
|
message_json['object']['object'])
|
||||||
return
|
return
|
||||||
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
||||||
|
|
||||||
|
|
@ -1564,8 +1568,9 @@ def outbox_mute(base_dir: str, http_prefix: str,
|
||||||
return
|
return
|
||||||
nickname_muted = get_nickname_from_actor(message_json['object'])
|
nickname_muted = get_nickname_from_actor(message_json['object'])
|
||||||
if not nickname_muted:
|
if not nickname_muted:
|
||||||
print('WARN: outbox_mute unable to find nickname in ' +
|
if debug:
|
||||||
message_json['object'])
|
print('WARN: outbox_mute unable to find nickname in ' +
|
||||||
|
message_json['object'])
|
||||||
return
|
return
|
||||||
|
|
||||||
mute_post(base_dir, nickname, domain, port,
|
mute_post(base_dir, nickname, domain, port,
|
||||||
|
|
@ -1629,8 +1634,9 @@ def outbox_undo_mute(base_dir: str, http_prefix: str,
|
||||||
return
|
return
|
||||||
nickname_muted = get_nickname_from_actor(message_json['object']['object'])
|
nickname_muted = get_nickname_from_actor(message_json['object']['object'])
|
||||||
if not nickname_muted:
|
if not nickname_muted:
|
||||||
print('WARN: outbox_undo_mute unable to find nickname in ' +
|
if debug:
|
||||||
message_json['object']['object'])
|
print('WARN: outbox_undo_mute unable to find nickname in ' +
|
||||||
|
message_json['object']['object'])
|
||||||
return
|
return
|
||||||
|
|
||||||
unmute_post(base_dir, nickname, domain, port,
|
unmute_post(base_dir, nickname, domain, port,
|
||||||
|
|
@ -1909,7 +1915,8 @@ def get_blocks_via_server(session, nickname: str, password: str,
|
||||||
https://codeberg.org/fediverse/fep/src/branch/main/fep/c648/fep-c648.md
|
https://codeberg.org/fediverse/fep/src/branch/main/fep/c648/fep-c648.md
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for get_blocks_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for get_blocks_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
auth_header = create_basic_auth_header(nickname, password)
|
auth_header = create_basic_auth_header(nickname, password)
|
||||||
|
|
@ -2216,8 +2223,9 @@ def _update_federated_blocks(session, base_dir: str,
|
||||||
debug = True
|
debug = True
|
||||||
|
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: federated blocklist ' +
|
if debug:
|
||||||
'no session for update_federated_blocks')
|
print('WARN: federated blocklist ' +
|
||||||
|
'no session for update_federated_blocks')
|
||||||
return block_federated
|
return block_federated
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
|
|
||||||
21
bookmarks.py
21
bookmarks.py
|
|
@ -265,8 +265,9 @@ def update_bookmarks_collection(recent_posts_cache: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: bookmark added to index')
|
print('DEBUG: bookmark added to index')
|
||||||
except OSError as ex:
|
except OSError as ex:
|
||||||
print('WARN: Failed to write entry to bookmarks index ' +
|
if debug:
|
||||||
bookmarks_index_filename + ' ' + str(ex))
|
print('WARN: Failed to write entry to bookmarks index ' +
|
||||||
|
bookmarks_index_filename + ' ' + str(ex))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
with open(bookmarks_index_filename, 'w+',
|
with open(bookmarks_index_filename, 'w+',
|
||||||
|
|
@ -405,7 +406,8 @@ def send_bookmark_via_server(base_dir: str, session,
|
||||||
"""Creates a bookmark via c2s
|
"""Creates a bookmark via c2s
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for send_bookmark_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for send_bookmark_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
domain_full = get_full_domain(domain, from_port)
|
domain_full = get_full_domain(domain, from_port)
|
||||||
|
|
@ -441,8 +443,9 @@ def send_bookmark_via_server(base_dir: str, session,
|
||||||
print('DEBUG: bookmark webfinger failed for ' + handle)
|
print('DEBUG: bookmark webfinger failed for ' + handle)
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wf_request, dict):
|
if not isinstance(wf_request, dict):
|
||||||
print('WARN: bookmark webfinger for ' + handle +
|
if debug:
|
||||||
' did not return a dict. ' + str(wf_request))
|
print('WARN: bookmark webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wf_request))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
post_to_box: str = 'outbox'
|
post_to_box: str = 'outbox'
|
||||||
|
|
@ -502,7 +505,8 @@ def send_undo_bookmark_via_server(base_dir: str, session,
|
||||||
"""Removes a bookmark via c2s
|
"""Removes a bookmark via c2s
|
||||||
"""
|
"""
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: No session for send_undo_bookmark_via_server')
|
if debug:
|
||||||
|
print('WARN: No session for send_undo_bookmark_via_server')
|
||||||
return 6
|
return 6
|
||||||
|
|
||||||
domain_full = get_full_domain(domain, from_port)
|
domain_full = get_full_domain(domain, from_port)
|
||||||
|
|
@ -538,8 +542,9 @@ def send_undo_bookmark_via_server(base_dir: str, session,
|
||||||
print('DEBUG: unbookmark webfinger failed for ' + handle)
|
print('DEBUG: unbookmark webfinger failed for ' + handle)
|
||||||
return 1
|
return 1
|
||||||
if not isinstance(wf_request, dict):
|
if not isinstance(wf_request, dict):
|
||||||
print('WARN: unbookmark webfinger for ' + handle +
|
if debug:
|
||||||
' did not return a dict. ' + str(wf_request))
|
print('WARN: unbookmark webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wf_request))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
post_to_box: str = 'outbox'
|
post_to_box: str = 'outbox'
|
||||||
|
|
|
||||||
|
|
@ -1818,8 +1818,9 @@ def save_media_in_form_post(media_bytes, debug: bool,
|
||||||
image_extension_types = get_image_extensions()
|
image_extension_types = get_image_extensions()
|
||||||
if detected_extension in image_extension_types:
|
if detected_extension in image_extension_types:
|
||||||
if not binary_is_image(filename, media_bytes[start_pos:]):
|
if not binary_is_image(filename, media_bytes[start_pos:]):
|
||||||
print('WARN: save_media_in_form_post ' +
|
if debug:
|
||||||
'image binary not recognized ' + filename)
|
print('WARN: save_media_in_form_post ' +
|
||||||
|
'image binary not recognized ' + filename)
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -1829,7 +1830,9 @@ def save_media_in_form_post(media_bytes, debug: bool,
|
||||||
print('EX: save_media_in_form_post unable to write media')
|
print('EX: save_media_in_form_post unable to write media')
|
||||||
|
|
||||||
if not os.path.isfile(filename):
|
if not os.path.isfile(filename):
|
||||||
print('WARN: Media file could not be written to file: ' + filename)
|
if debug:
|
||||||
|
print('WARN: Media file could not be written to file: ' +
|
||||||
|
filename)
|
||||||
return None, None
|
return None, None
|
||||||
print('Uploaded media file written: ' + filename)
|
print('Uploaded media file written: ' + filename)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.server.starting_daemon:
|
if self.server.starting_daemon:
|
||||||
return
|
return
|
||||||
if check_bad_path(self.path):
|
if check_bad_path(self.path):
|
||||||
print('WARN: bad pathx PROPFIND ' + self.path)
|
print('WARN: bad path PROPFIND ' + self.path)
|
||||||
http_400(self)
|
http_400(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -265,7 +265,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if self.server.starting_daemon:
|
if self.server.starting_daemon:
|
||||||
return
|
return
|
||||||
if check_bad_path(self.path):
|
if check_bad_path(self.path):
|
||||||
print('WARN: bad path PROPFIND ' + self.path)
|
print('WARN: bad path PUT ' + self.path)
|
||||||
http_400(self)
|
http_400(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue