Blocking using actors

master
Bob Mottram 2019-08-13 17:39:43 +01:00
parent f9ccef4f3b
commit b410de1a7b
2 changed files with 27 additions and 7 deletions

View File

@ -2143,11 +2143,31 @@ class PubServer(BaseHTTPRequestHandler):
if moderationButton=='unsuspend': if moderationButton=='unsuspend':
unsuspendAccount(self.server.baseDir,nickname) unsuspendAccount(self.server.baseDir,nickname)
if moderationButton=='block': if moderationButton=='block':
fullBlockDomain=None
if moderationText.startswith('http') or \
moderationText.startswith('dat'):
blockDomain,blockPort=getDomainFromActor(moderationText)
fullBlockDomain=blockDomain
if blockPort:
if blockPort!=80 and blockPort!=443:
fullBlockDomain=blockDomain+':'+str(blockPort)
if '@' in moderationText:
fullBlockDomain=moderationText.split('@')[1] fullBlockDomain=moderationText.split('@')[1]
if fullBlockDomain:
addGlobalBlock(self.server.baseDir, \ addGlobalBlock(self.server.baseDir, \
nickname,fullBlockDomain) nickname,fullBlockDomain)
if moderationButton=='unblock': if moderationButton=='unblock':
fullBlockDomain=None
if moderationText.startswith('http') or \
moderationText.startswith('dat'):
blockDomain,blockPort=getDomainFromActor(moderationText)
fullBlockDomain=blockDomain
if blockPort:
if blockPort!=80 and blockPort!=443:
fullBlockDomain=blockDomain+':'+str(blockPort)
if '@' in moderationText:
fullBlockDomain=moderationText.split('@')[1] fullBlockDomain=moderationText.split('@')[1]
if fullBlockDomain:
removeGlobalBlock(self.server.baseDir, \ removeGlobalBlock(self.server.baseDir, \
nickname,fullBlockDomain) nickname,fullBlockDomain)
if moderationButton=='remove': if moderationButton=='remove':

View File

@ -1069,7 +1069,7 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
tlStr+= \ tlStr+= \
'<form method="POST" action="/users/'+nickname+'/moderationaction">' \ '<form method="POST" action="/users/'+nickname+'/moderationaction">' \
'<div class="container">\n'+ \ '<div class="container">\n'+ \
' <input type="text" placeholder="Nickname or URL..." name="moderationAction" value="">' \ ' <input type="text" placeholder="Nickname or URL. Block using *@domain or nickname@domain" name="moderationAction" value="">' \
' <input type="submit" title="Remove the above item" name="submitRemove" value="Remove">' \ ' <input type="submit" title="Remove the above item" name="submitRemove" value="Remove">' \
' <input type="submit" title="Suspend the above account nickname" name="submitSuspend" value="Suspend">' \ ' <input type="submit" title="Suspend the above account nickname" name="submitSuspend" value="Suspend">' \
' <input type="submit" title="Remove a suspension for an account nickname" name="submitUnsuspend" value="Unsuspend">' \ ' <input type="submit" title="Remove a suspension for an account nickname" name="submitUnsuspend" value="Unsuspend">' \