forked from indymedia/epicyon
Easier way to block domains
parent
0e15d936b3
commit
ac67db1679
|
@ -21,18 +21,22 @@ def addGlobalBlock(baseDir: str,
|
|||
"""
|
||||
blockingFilename = baseDir + '/accounts/blocking.txt'
|
||||
if not blockNickname.startswith('#'):
|
||||
# is the handle already blocked?
|
||||
blockHandle = blockNickname + '@' + blockDomain
|
||||
if os.path.isfile(blockingFilename):
|
||||
if blockHandle in open(blockingFilename).read():
|
||||
return False
|
||||
# block an account handle or domain
|
||||
blockFile = open(blockingFilename, "a+")
|
||||
blockFile.write(blockHandle + '\n')
|
||||
blockFile.close()
|
||||
else:
|
||||
blockHashtag = blockNickname
|
||||
# is the hashtag already blocked?
|
||||
if os.path.isfile(blockingFilename):
|
||||
if blockHashtag + '\n' in open(blockingFilename).read():
|
||||
return False
|
||||
# block a hashtag
|
||||
blockFile = open(blockingFilename, "a+")
|
||||
blockFile.write(blockHashtag + '\n')
|
||||
blockFile.close()
|
||||
|
|
14
daemon.py
14
daemon.py
|
@ -1407,6 +1407,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fullBlockDomain = None
|
||||
if moderationText.startswith('http') or \
|
||||
moderationText.startswith('dat'):
|
||||
# https://domain
|
||||
blockDomain, blockPort = \
|
||||
getDomainFromActor(moderationText)
|
||||
fullBlockDomain = blockDomain
|
||||
|
@ -1416,13 +1417,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fullBlockDomain = \
|
||||
blockDomain + ':' + str(blockPort)
|
||||
if '@' in moderationText:
|
||||
# nick@domain or *@domain
|
||||
fullBlockDomain = moderationText.split('@')[1]
|
||||
else:
|
||||
# assume the text is a domain name
|
||||
if not fullBlockDomain and '.' in moderationText:
|
||||
nickname = '*'
|
||||
fullBlockDomain = moderationText.strip()
|
||||
if fullBlockDomain or nickname.startswith('#'):
|
||||
addGlobalBlock(baseDir, nickname, fullBlockDomain)
|
||||
if moderationButton == 'unblock':
|
||||
fullBlockDomain = None
|
||||
if moderationText.startswith('http') or \
|
||||
moderationText.startswith('dat'):
|
||||
# https://domain
|
||||
blockDomain, blockPort = \
|
||||
getDomainFromActor(moderationText)
|
||||
fullBlockDomain = blockDomain
|
||||
|
@ -1432,7 +1440,13 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fullBlockDomain = \
|
||||
blockDomain + ':' + str(blockPort)
|
||||
if '@' in moderationText:
|
||||
# nick@domain or *@domain
|
||||
fullBlockDomain = moderationText.split('@')[1]
|
||||
else:
|
||||
# assume the text is a domain name
|
||||
if not fullBlockDomain and '.' in moderationText:
|
||||
nickname = '*'
|
||||
fullBlockDomain = moderationText.strip()
|
||||
if fullBlockDomain or nickname.startswith('#'):
|
||||
removeGlobalBlock(baseDir, nickname, fullBlockDomain)
|
||||
if moderationButton == 'remove':
|
||||
|
|
Loading…
Reference in New Issue