mirror of https://gitlab.com/bashrc2/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?
|
"""Is the given nickname blocked?
|
||||||
"""
|
"""
|
||||||
blockingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt'
|
blockingFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt'
|
||||||
blockHandle=blockNickName+'@'+blockDomain
|
blockHandle=blockNickname+'@'+blockDomain
|
||||||
if os.path.isfile(blockingFilename):
|
if os.path.isfile(blockingFilename):
|
||||||
if blockHandle in open(blockingFilename).read():
|
if blockHandle in open(blockingFilename).read():
|
||||||
return True
|
return True
|
||||||
|
|
10
inbox.py
10
inbox.py
|
@ -36,6 +36,7 @@ from capabilities import CapablePost
|
||||||
from capabilities import capabilitiesReceiveUpdate
|
from capabilities import capabilitiesReceiveUpdate
|
||||||
from like import updateLikesCollection
|
from like import updateLikesCollection
|
||||||
from like import undoLikesCollectionEntry
|
from like import undoLikesCollectionEntry
|
||||||
|
from blocking import isBlocked
|
||||||
|
|
||||||
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool) -> str:
|
def getPersonPubKey(session,personUrl: str,personCache: {},debug: bool) -> str:
|
||||||
if not personUrl:
|
if not personUrl:
|
||||||
|
@ -117,6 +118,15 @@ def savePostToInboxQueue(baseDir: str,httpPrefix: str,nickname: str, domain: str
|
||||||
"""
|
"""
|
||||||
if ':' in domain:
|
if ':' in domain:
|
||||||
domain=domain.split(':')[0]
|
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'):
|
if postJsonObject.get('id'):
|
||||||
postId=postJsonObject['id'].replace('/activity','')
|
postId=postJsonObject['id'].replace('/activity','')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue