Alternative pattern for undo follow

main
Bob Mottram 2023-07-12 23:28:38 +01:00
parent c8b31d56d2
commit f3620ff2a0
1 changed files with 14 additions and 3 deletions

View File

@ -1042,6 +1042,8 @@ def _receive_undo_follow(base_dir: str, message_json: {},
} }
} }
""" """
if not message_json['object'].get('object'):
return False
if not message_json['object'].get('actor'): if not message_json['object'].get('actor'):
if debug: if debug:
print('DEBUG: undo follow request has no actor within object') print('DEBUG: undo follow request has no actor within object')
@ -1071,8 +1073,19 @@ def _receive_undo_follow(base_dir: str, message_json: {},
return False return False
domain_follower_full = get_full_domain(domain_follower, port_follower) domain_follower_full = get_full_domain(domain_follower, port_follower)
following_actor = None
if isinstance(message_json['object']['object'], str):
following_actor = message_json['object']['object']
elif isinstance(message_json['object']['object'], dict):
if message_json['object']['object'].get('id'):
if isinstance(message_json['object']['object']['id'], str):
following_actor = message_json['object']['object']['id']
if not following_actor:
print('WARN: undo follow without following actor')
return False
nickname_following = \ nickname_following = \
get_nickname_from_actor(message_json['object']['object']) get_nickname_from_actor(following_actor)
if not nickname_following: if not nickname_following:
print('WARN: undo follow request unable to find nickname in ' + print('WARN: undo follow request unable to find nickname in ' +
message_json['object']['object']) message_json['object']['object'])
@ -1125,8 +1138,6 @@ def _receive_undo(base_dir: str, message_json: {}, debug: bool,
return False return False
if not has_object_string_type(message_json, debug): if not has_object_string_type(message_json, debug):
return False return False
if not has_object_string_object(message_json, debug):
return False
if message_json['object']['type'] == 'Follow' or \ if message_json['object']['type'] == 'Follow' or \
message_json['object']['type'] == 'Join': message_json['object']['type'] == 'Join':
_receive_undo_follow(base_dir, message_json, _receive_undo_follow(base_dir, message_json,