diff --git a/blocking.py b/blocking.py index bbe9d3f9f..e9440e431 100644 --- a/blocking.py +++ b/blocking.py @@ -7,6 +7,7 @@ __email__ = "bob@freedombone.net" __status__ = "Production" import os +from utils import isEvil def addGlobalBlock(baseDir: str, \ blockNickname: str,blockDomain: str) -> bool: @@ -116,11 +117,8 @@ def isBlocked(baseDir: str,nickname: str,domain: str, \ blockNickname: str,blockDomain: str) -> bool: """Is the given nickname blocked? """ - # https://www.youtube.com/watch?v=5qw1hcevmdU - evilDomains=['gab.com','gabfed.com','spinster.xyz'] - for concentratedEvil in evilDomains: - if blockDomain.endswith(concentratedEvil): - return True + if isEvil(blockDomain): + return True globalBlockingFilename=baseDir+'/accounts/blocking.txt' if os.path.isfile(globalBlockingFilename): if '*@'+blockDomain in open(globalBlockingFilename).read(): diff --git a/utils.py b/utils.py index bc6f8f4c2..c3ed134b4 100644 --- a/utils.py +++ b/utils.py @@ -20,6 +20,14 @@ def getStatusNumber() -> (str,str): published=currTime.strftime("%Y-%m-%dT%H:%M:%SZ") return statusNumber,published +def isEvil(domain: str) -> bool: + # https://www.youtube.com/watch?v=5qw1hcevmdU + evilDomains=['gab.com','gabfed.com','spinster.xyz'] + for concentratedEvil in evilDomains: + if domain.endswith(concentratedEvil): + return True + return False + def createPersonDir(nickname: str,domain: str,baseDir: str,dirname: str) -> str: """Create a directory for a person """ @@ -51,11 +59,8 @@ def domainPermitted(domain: str, federationList: []): return False def urlPermitted(url: str, federationList: [],capability: str): - # https://www.youtube.com/watch?v=5qw1hcevmdU - evilDomains=['gab.com','gabfed.com','spinster.xyz'] - for concentratedEvil in evilDomains: - if url.endswith(concentratedEvil): - return False + if isEvil(url): + return False if len(federationList)==0: return True for domain in federationList: