Class method for checking if urls are blocked

This commit is contained in:
Mouse Reeve
2021-04-10 11:38:57 -07:00
parent 0caeb3ac33
commit 1903812b1d
3 changed files with 17 additions and 15 deletions

View File

@ -1,4 +1,5 @@
""" connections to external ActivityPub servers """
from urllib.parse import urlparse
from django.db import models
from .base_model import BookWyrmModel
@ -38,3 +39,10 @@ class FederatedServer(BookWyrmModel):
# TODO: only reactivate users as appropriate
self.user_set.update(is_active=True)
@classmethod
def is_blocked(cls, url):
""" look up if a domain is blocked """
url = urlparse(url)
domain = url.netloc
return cls.objects.filter(server_name=domain, status="blocked").exists()