mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
avoid AttributeError when instance inbox is not populated
This commit is contained in:
parent
12e6e55cb4
commit
15c628903d
2 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue