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