forked from indymedia/epicyon
Block incoming items at the earliest stage, before anything is written to file
parent
645f45cfcb
commit
7b8f88fd1b
|
@ -46,7 +46,7 @@ def isBlocked(baseDir: str,nickname: str,domain: str, \
|
|||
"""Is the given nickname blocked?
|
||||
"""
|
||||
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 True
|
||||
|
|
10
inbox.py
10
inbox.py
|
@ -36,6 +36,7 @@ from capabilities import CapablePost
|
|||
from capabilities import capabilitiesReceiveUpdate
|
||||
from like import updateLikesCollection
|
||||
from like import undoLikesCollectionEntry
|
||||
from blocking import isBlocked
|
||||
|
||||
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool) -> str:
|
||||
if not personUrl:
|
||||
|
@ -117,6 +118,15 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str
|
|||
"""
|
||||
if ':' in domain:
|
||||
domain=domain.split(':')[0]
|
||||
|
||||
# block at the ealiest stage possible, which means the data
|
||||
# isn't written to file
|
||||
if postJsonObject.get('actor'):
|
||||
postNickname=getNicknameFromActor(postJsonObject['actor'])
|
||||
postDomain,postPort=getDomainFromActor(postJsonObject['actor'])
|
||||
if isBlocked(baseDir,nickname,domain,postNickname,postDomain):
|
||||
return None
|
||||
|
||||
if postJsonObject.get('id'):
|
||||
postId=postJsonObject['id'].replace('/activity','')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue