Check for type

main
Bob Mottram 2022-03-23 22:24:49 +00:00
parent 44d386db86
commit 95eed2183a
2 changed files with 13 additions and 7 deletions

View File

@ -6657,14 +6657,16 @@ class PubServer(BaseHTTPRequestHandler):
# this account is a bot # this account is a bot
if fields.get('isBot'): if fields.get('isBot'):
if fields['isBot'] == 'on': if fields['isBot'] == 'on' and \
actor_json.get('type'):
if actor_json['type'] != 'Service': if actor_json['type'] != 'Service':
actor_json['type'] = 'Service' actor_json['type'] = 'Service'
actor_changed = True actor_changed = True
else: else:
# this account is a group # this account is a group
if fields.get('isGroup'): if fields.get('isGroup'):
if fields['isGroup'] == 'on': if fields['isGroup'] == 'on' and \
actor_json.get('type'):
if actor_json['type'] != 'Group': if actor_json['type'] != 'Group':
# only allow admin to create groups # only allow admin to create groups
if path.startswith('/users/' + if path.startswith('/users/' +
@ -6673,9 +6675,10 @@ class PubServer(BaseHTTPRequestHandler):
actor_changed = True actor_changed = True
else: else:
# this account is a person (default) # this account is a person (default)
if actor_json['type'] != 'Person': if actor_json.get('type'):
actor_json['type'] = 'Person' if actor_json['type'] != 'Person':
actor_changed = True actor_json['type'] = 'Person'
actor_changed = True
# grayscale theme # grayscale theme
if path.startswith('/users/' + admin_nickname + '/') or \ if path.startswith('/users/' + admin_nickname + '/') or \
@ -7700,8 +7703,9 @@ class PubServer(BaseHTTPRequestHandler):
moved_to = actor_json['movedTo'] moved_to = actor_json['movedTo']
if '"' in moved_to: if '"' in moved_to:
moved_to = moved_to.split('"')[1] moved_to = moved_to.split('"')[1]
if actor_json['type'] == 'Group': if actor_json.get('type'):
is_group = True if actor_json['type'] == 'Group':
is_group = True
locked_account = get_locked_account(actor_json) locked_account = get_locked_account(actor_json)
donate_url = get_donation_url(actor_json) donate_url = get_donation_url(actor_json)
website_url = get_website(actor_json, self.server.translate) website_url = get_website(actor_json, self.server.translate)

View File

@ -2690,6 +2690,8 @@ def _group_handle(base_dir: str, handle: str) -> bool:
actor_json = load_json(actor_file) actor_json = load_json(actor_file)
if not actor_json: if not actor_json:
return False return False
if not actor_json.get('type'):
return False
return actor_json['type'] == 'Group' return actor_json['type'] == 'Group'