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:
|
||||
print('DEBUG: receiving Follow activity')
|
||||
if not message_json['object'].get('actor'):
|
||||
print('DEBUG: no actor in Follow activity')
|
||||
if debug:
|
||||
print('DEBUG: no actor in Follow activity')
|
||||
return
|
||||
# no, this isn't a mistake
|
||||
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'])
|
||||
nickname = get_nickname_from_actor(this_actor)
|
||||
if not nickname:
|
||||
print('WARN: no nickname found in ' + this_actor)
|
||||
if debug:
|
||||
print('WARN: no nickname found in ' + this_actor)
|
||||
return
|
||||
accepted_domain, accepted_port = get_domain_from_actor(this_actor)
|
||||
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)
|
||||
nickname = get_nickname_from_actor(actor_url)
|
||||
if not nickname:
|
||||
print('WARN: no nickname found in ' + actor_url)
|
||||
if debug:
|
||||
print('WARN: no nickname found in ' + actor_url)
|
||||
return False
|
||||
domain, _ = get_domain_from_actor(actor_url)
|
||||
if not domain:
|
||||
print('WARN: no domain found in ' + actor_url)
|
||||
if debug:
|
||||
print('WARN: no domain found in ' + actor_url)
|
||||
return False
|
||||
post_filename = locate_post(base_dir, nickname, domain,
|
||||
message_json['object'])
|
||||
|
|
@ -131,11 +133,13 @@ def outbox_announce(recent_posts_cache: {},
|
|||
actor_url = get_actor_from_post(message_json)
|
||||
nickname = get_nickname_from_actor(actor_url)
|
||||
if not nickname:
|
||||
print('WARN: no nickname found in ' + actor_url)
|
||||
if debug:
|
||||
print('WARN: no nickname found in ' + actor_url)
|
||||
return False
|
||||
domain, _ = get_domain_from_actor(actor_url)
|
||||
if not domain:
|
||||
print('WARN: no domain found in ' + actor_url)
|
||||
if debug:
|
||||
print('WARN: no domain found in ' + actor_url)
|
||||
return False
|
||||
post_filename = locate_post(base_dir, nickname, domain,
|
||||
message_json['object']['object'])
|
||||
|
|
@ -294,7 +298,8 @@ def send_announce_via_server(base_dir: str, session,
|
|||
"""Creates an announce message via c2s
|
||||
"""
|
||||
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
|
||||
|
||||
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)
|
||||
return 1
|
||||
if not isinstance(wf_request, dict):
|
||||
print('WARN: announce webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
if debug:
|
||||
print('WARN: announce webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
return 1
|
||||
|
||||
post_to_box: str = 'outbox'
|
||||
|
|
@ -371,7 +377,8 @@ def send_announce_via_server(base_dir: str, session,
|
|||
session, new_announce_json, [], inbox_url,
|
||||
headers, 3, True)
|
||||
if not post_result:
|
||||
print('WARN: announce not posted')
|
||||
if debug:
|
||||
print('WARN: announce not posted')
|
||||
|
||||
if debug:
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
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)
|
||||
return 1
|
||||
if not isinstance(wf_request, dict):
|
||||
print('WARN: undo announce webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
if debug:
|
||||
print('WARN: undo announce webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
return 1
|
||||
|
||||
post_to_box: str = 'outbox'
|
||||
|
|
@ -460,7 +469,8 @@ def send_undo_announce_via_server(base_dir: str, session,
|
|||
session, unannounce_json, [], inbox_url,
|
||||
headers, 3, True)
|
||||
if not post_result:
|
||||
print('WARN: undo announce not posted')
|
||||
if debug:
|
||||
print('WARN: undo announce not posted')
|
||||
|
||||
if debug:
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
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)
|
||||
return 1
|
||||
if not isinstance(wf_request, dict):
|
||||
print('WARN: availability webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
if debug:
|
||||
print('WARN: availability webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
return 1
|
||||
|
||||
post_to_box: str = 'outbox'
|
||||
|
|
@ -178,7 +180,8 @@ def send_availability_via_server(base_dir: str, session,
|
|||
session, new_availability_json, [],
|
||||
inbox_url, headers, 30, True)
|
||||
if not post_result:
|
||||
print('WARN: availability failed to post')
|
||||
if debug:
|
||||
print('WARN: availability failed to post')
|
||||
|
||||
if debug:
|
||||
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
|
||||
nickname_blocked = get_nickname_from_actor(message_json['object'])
|
||||
if not nickname_blocked:
|
||||
print('WARN: outbox_block unable to find nickname in ' +
|
||||
message_json['object'])
|
||||
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:
|
||||
print('WARN: outbox_block unable to find domain in ' +
|
||||
message_json['object'])
|
||||
if debug:
|
||||
print('WARN: outbox_block unable to find domain in ' +
|
||||
message_json['object'])
|
||||
return False
|
||||
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 = \
|
||||
get_nickname_from_actor(message_json['object']['object'])
|
||||
if not nickname_blocked:
|
||||
print('WARN: outbox_undo_block unable to find nickname in ' +
|
||||
message_json['object']['object'])
|
||||
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:
|
||||
print('WARN: outbox_undo_block unable to find domain in ' +
|
||||
message_json['object']['object'])
|
||||
if debug:
|
||||
print('WARN: outbox_undo_block unable to find domain in ' +
|
||||
message_json['object']['object'])
|
||||
return
|
||||
domain_blocked_full = get_full_domain(domain_blocked, port_blocked)
|
||||
|
||||
|
|
@ -1564,8 +1568,9 @@ def outbox_mute(base_dir: str, http_prefix: str,
|
|||
return
|
||||
nickname_muted = get_nickname_from_actor(message_json['object'])
|
||||
if not nickname_muted:
|
||||
print('WARN: outbox_mute unable to find nickname in ' +
|
||||
message_json['object'])
|
||||
if debug:
|
||||
print('WARN: outbox_mute unable to find nickname in ' +
|
||||
message_json['object'])
|
||||
return
|
||||
|
||||
mute_post(base_dir, nickname, domain, port,
|
||||
|
|
@ -1629,8 +1634,9 @@ 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:
|
||||
print('WARN: outbox_undo_mute unable to find nickname in ' +
|
||||
message_json['object']['object'])
|
||||
if debug:
|
||||
print('WARN: outbox_undo_mute unable to find nickname in ' +
|
||||
message_json['object']['object'])
|
||||
return
|
||||
|
||||
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
|
||||
"""
|
||||
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
|
||||
|
||||
auth_header = create_basic_auth_header(nickname, password)
|
||||
|
|
@ -2216,8 +2223,9 @@ def _update_federated_blocks(session, base_dir: str,
|
|||
debug = True
|
||||
|
||||
if not session:
|
||||
print('WARN: federated blocklist ' +
|
||||
'no session for update_federated_blocks')
|
||||
if debug:
|
||||
print('WARN: federated blocklist ' +
|
||||
'no session for update_federated_blocks')
|
||||
return block_federated
|
||||
|
||||
headers = {
|
||||
|
|
|
|||
21
bookmarks.py
21
bookmarks.py
|
|
@ -265,8 +265,9 @@ def update_bookmarks_collection(recent_posts_cache: {},
|
|||
if debug:
|
||||
print('DEBUG: bookmark added to index')
|
||||
except OSError as ex:
|
||||
print('WARN: Failed to write entry to bookmarks index ' +
|
||||
bookmarks_index_filename + ' ' + str(ex))
|
||||
if debug:
|
||||
print('WARN: Failed to write entry to bookmarks index ' +
|
||||
bookmarks_index_filename + ' ' + str(ex))
|
||||
else:
|
||||
try:
|
||||
with open(bookmarks_index_filename, 'w+',
|
||||
|
|
@ -405,7 +406,8 @@ def send_bookmark_via_server(base_dir: str, session,
|
|||
"""Creates a bookmark via c2s
|
||||
"""
|
||||
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
|
||||
|
||||
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)
|
||||
return 1
|
||||
if not isinstance(wf_request, dict):
|
||||
print('WARN: bookmark webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
if debug:
|
||||
print('WARN: bookmark webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
return 1
|
||||
|
||||
post_to_box: str = 'outbox'
|
||||
|
|
@ -502,7 +505,8 @@ def send_undo_bookmark_via_server(base_dir: str, session,
|
|||
"""Removes a bookmark via c2s
|
||||
"""
|
||||
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
|
||||
|
||||
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)
|
||||
return 1
|
||||
if not isinstance(wf_request, dict):
|
||||
print('WARN: unbookmark webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
if debug:
|
||||
print('WARN: unbookmark webfinger for ' + handle +
|
||||
' did not return a dict. ' + str(wf_request))
|
||||
return 1
|
||||
|
||||
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()
|
||||
if detected_extension in image_extension_types:
|
||||
if not binary_is_image(filename, media_bytes[start_pos:]):
|
||||
print('WARN: save_media_in_form_post ' +
|
||||
'image binary not recognized ' + filename)
|
||||
if debug:
|
||||
print('WARN: save_media_in_form_post ' +
|
||||
'image binary not recognized ' + filename)
|
||||
return None, None
|
||||
|
||||
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')
|
||||
|
||||
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