Global blocking domains

master
Bob Mottram 2019-08-13 17:11:29 +01:00
parent 812ad29de2
commit f9ccef4f3b
2 changed files with 6 additions and 15 deletions

View File

@ -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:

View File

@ -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':