From f9ccef4f3bf427bbdc0b475b00094edfc6541291 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 13 Aug 2019 17:11:29 +0100 Subject: [PATCH] Global blocking domains --- blocking.py | 8 ++++---- daemon.py | 13 ++----------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/blocking.py b/blocking.py index d664000ba..86048f36d 100644 --- a/blocking.py +++ b/blocking.py @@ -13,7 +13,7 @@ def addGlobalBlock(baseDir: str, \ """Global block which applies to all accounts """ blockingFilename=baseDir+'/accounts/blocking.txt' - blockHandle=blockNickName+'@'+blockDomain + blockHandle=blockNickname+'@'+blockDomain if os.path.isfile(blockingFilename): if blockHandle in open(blockingFilename).read(): return False @@ -29,7 +29,7 @@ def addBlock(baseDir: str,nickname: str,domain: str, \ if ':' in domain: domain=domain.split(':')[0] blockingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt' - blockHandle=blockNickName+'@'+blockDomain + blockHandle=blockNickname+'@'+blockDomain if os.path.isfile(blockingFilename): if blockHandle in open(blockingFilename).read(): return False @@ -44,7 +44,7 @@ def removeGlobalBlock(baseDir: str, \ """Unblock the given global block """ unblockingFilename=baseDir+'/accounts/blocking.txt' - unblockHandle=unblockNickName+'@'+unblockDomain + unblockHandle=unblockNickname+'@'+unblockDomain if os.path.isfile(unblockingFilename): if unblockHandle in open(unblockingFilename).read(): with open(unblockingFilename, 'r') as fp: @@ -65,7 +65,7 @@ def removeBlock(baseDir: str,nickname: str,domain: str, \ if ':' in domain: domain=domain.split(':')[0] unblockingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt' - unblockHandle=unblockNickName+'@'+unblockDomain + unblockHandle=unblockNickname+'@'+unblockDomain if os.path.isfile(unblockingFilename): if unblockHandle in open(unblockingFilename).read(): with open(unblockingFilename, 'r') as fp: diff --git a/daemon.py b/daemon.py index c089ff78a..bee03e797 100644 --- a/daemon.py +++ b/daemon.py @@ -2139,24 +2139,15 @@ class PubServer(BaseHTTPRequestHandler): if '@' in nickname: nickname=nickname.split('@')[0] if moderationButton=='suspend': - print('**************** suspend') suspendAccount(self.server.baseDir,nickname,self.server.salts) if moderationButton=='unsuspend': unsuspendAccount(self.server.baseDir,nickname) if moderationButton=='block': - blockDomain,blockPort=getDomainFromActor(moderationText) - fullBlockDomain=blockDomain - if blockPort: - if blockPort!=80 and blockPort!=443: - fullBlockDomain=blockDomain+':'+str(blockPort) + fullBlockDomain=moderationText.split('@')[1] addGlobalBlock(self.server.baseDir, \ nickname,fullBlockDomain) if moderationButton=='unblock': - blockDomain,blockPort=getDomainFromActor(moderationText) - fullBlockDomain=blockDomain - if blockPort: - if blockPort!=80 and blockPort!=443: - fullBlockDomain=blockDomain+':'+str(blockPort) + fullBlockDomain=moderationText.split('@')[1] removeGlobalBlock(self.server.baseDir, \ nickname,fullBlockDomain) if moderationButton=='remove':