mirror of https://gitlab.com/bashrc2/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 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, \
|
||||
blockNickname: str,blockDomain: str) -> bool:
|
||||
"""Is the given nickname blocked?
|
||||
|
|
8
inbox.py
8
inbox.py
|
@ -42,6 +42,7 @@ from blocking import isBlocked
|
|||
from filters import isFiltered
|
||||
from announce import updateAnnounceCollection
|
||||
from httpsig import messageContentDigest
|
||||
from blocking import isBlockedDomain
|
||||
|
||||
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
|
||||
"""Checks whether files were correctly saved to the inbox
|
||||
|
@ -918,6 +919,13 @@ def receiveAnnounce(session,handle: str,baseDir: str, \
|
|||
if debug:
|
||||
print('DEBUG: "statuses" missing from object in '+messageJson['type'])
|
||||
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):
|
||||
print('DEBUG: unknown recipient of announce - '+handle)
|
||||
# is this post in the outbox of the person?
|
||||
|
|
Loading…
Reference in New Issue