From 95eed2183a8eb006ef786370e0118902ae486308 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 23 Mar 2022 22:24:49 +0000 Subject: [PATCH] Check for type --- daemon.py | 18 +++++++++++------- inbox.py | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/daemon.py b/daemon.py index 421456f21..1c3d22acb 100644 --- a/daemon.py +++ b/daemon.py @@ -6657,14 +6657,16 @@ class PubServer(BaseHTTPRequestHandler): # this account is a bot if fields.get('isBot'): - if fields['isBot'] == 'on': + if fields['isBot'] == 'on' and \ + actor_json.get('type'): if actor_json['type'] != 'Service': actor_json['type'] = 'Service' actor_changed = True else: # this account is a group if fields.get('isGroup'): - if fields['isGroup'] == 'on': + if fields['isGroup'] == 'on' and \ + actor_json.get('type'): if actor_json['type'] != 'Group': # only allow admin to create groups if path.startswith('/users/' + @@ -6673,9 +6675,10 @@ class PubServer(BaseHTTPRequestHandler): actor_changed = True else: # this account is a person (default) - if actor_json['type'] != 'Person': - actor_json['type'] = 'Person' - actor_changed = True + if actor_json.get('type'): + if actor_json['type'] != 'Person': + actor_json['type'] = 'Person' + actor_changed = True # grayscale theme if path.startswith('/users/' + admin_nickname + '/') or \ @@ -7700,8 +7703,9 @@ class PubServer(BaseHTTPRequestHandler): moved_to = actor_json['movedTo'] if '"' in moved_to: moved_to = moved_to.split('"')[1] - if actor_json['type'] == 'Group': - is_group = True + if actor_json.get('type'): + if actor_json['type'] == 'Group': + is_group = True locked_account = get_locked_account(actor_json) donate_url = get_donation_url(actor_json) website_url = get_website(actor_json, self.server.translate) diff --git a/inbox.py b/inbox.py index 7006a156d..2aeb4df21 100644 --- a/inbox.py +++ b/inbox.py @@ -2690,6 +2690,8 @@ def _group_handle(base_dir: str, handle: str) -> bool: actor_json = load_json(actor_file) if not actor_json: return False + if not actor_json.get('type'): + return False return actor_json['type'] == 'Group'