forked from indymedia/epicyon
Check for blocked domains being announced
parent
a90039b57a
commit
28d30ed497
11
blocking.py
11
blocking.py
|
@ -113,6 +113,17 @@ def isBlockedHashtag(baseDir: str,hashtag: str) -> bool:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def isBlockedDomain(baseDir: str,domain: str) -> bool:
|
||||||
|
"""Is the given domain blocked?
|
||||||
|
"""
|
||||||
|
if isEvil(domain):
|
||||||
|
return True
|
||||||
|
globalBlockingFilename=baseDir+'/accounts/blocking.txt'
|
||||||
|
if os.path.isfile(globalBlockingFilename):
|
||||||
|
if '*@'+domain in open(globalBlockingFilename).read():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def isBlocked(baseDir: str,nickname: str,domain: str, \
|
def isBlocked(baseDir: str,nickname: str,domain: str, \
|
||||||
blockNickname: str,blockDomain: str) -> bool:
|
blockNickname: str,blockDomain: str) -> bool:
|
||||||
"""Is the given nickname blocked?
|
"""Is the given nickname blocked?
|
||||||
|
|
8
inbox.py
8
inbox.py
|
@ -42,6 +42,7 @@ from blocking import isBlocked
|
||||||
from filters import isFiltered
|
from filters import isFiltered
|
||||||
from announce import updateAnnounceCollection
|
from announce import updateAnnounceCollection
|
||||||
from httpsig import messageContentDigest
|
from httpsig import messageContentDigest
|
||||||
|
from blocking import isBlockedDomain
|
||||||
|
|
||||||
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
|
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
"""Checks whether files were correctly saved to the inbox
|
"""Checks whether files were correctly saved to the inbox
|
||||||
|
@ -918,6 +919,13 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: "statuses" missing from object in '+messageJson['type'])
|
print('DEBUG: "statuses" missing from object in '+messageJson['type'])
|
||||||
return False
|
return False
|
||||||
|
objectDomain=messageJson['object'].replace('https://','').replace('http://','').replace('dat://','')
|
||||||
|
if '/' in objectDomain:
|
||||||
|
objectDomain=objectDomain.split('/')[0]
|
||||||
|
if isBlockedDomain(baseDir,objectDomain):
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: announced domain is blocked')
|
||||||
|
return False
|
||||||
if not os.path.isdir(baseDir+'/accounts/'+handle):
|
if not os.path.isdir(baseDir+'/accounts/'+handle):
|
||||||
print('DEBUG: unknown recipient of announce - '+handle)
|
print('DEBUG: unknown recipient of announce - '+handle)
|
||||||
# is this post in the outbox of the person?
|
# is this post in the outbox of the person?
|
||||||
|
|
Loading…
Reference in New Issue