avoid AttributeError when instance inbox is not populated

This commit is contained in:
rimu 2024-04-09 19:23:19 +12:00
parent 12e6e55cb4
commit 15c628903d
2 changed files with 6 additions and 0 deletions

View file

@ -223,6 +223,8 @@ def banned_user_agents():
@cache.memoize(150)
def instance_blocked(host: str) -> bool: # see also utils.instance_banned()
if host is None or host == '':
return True
host = host.lower()
if 'https://' in host or 'http://' in host:
host = urlparse(host).hostname
@ -232,6 +234,8 @@ def instance_blocked(host: str) -> bool: # see also utils.instance_banned
@cache.memoize(150)
def instance_allowed(host: str) -> bool:
if host is None or host == '':
return True
host = host.lower()
if 'https://' in host or 'http://' in host:
host = urlparse(host).hostname

View file

@ -451,6 +451,8 @@ def user_ip_banned() -> bool:
@cache.memoize(timeout=30)
def instance_banned(domain: str) -> bool: # see also activitypub.util.instance_blocked()
if domain is None or domain == '':
return False
banned = BannedInstances.query.filter_by(domain=domain).first()
return banned is not None