mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
99035b1b7b
commit
4555917eeb
52
inbox.py
52
inbox.py
|
@ -2263,42 +2263,52 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
postIsDM = isDM(postJsonObject)
|
postIsDM = isDM(postJsonObject)
|
||||||
if postIsDM:
|
if postIsDM:
|
||||||
if nickname != 'inbox':
|
if nickname != 'inbox':
|
||||||
|
# check for the flag file which indicates to
|
||||||
|
# only receive DMs from people you are following
|
||||||
followDMsFilename = \
|
followDMsFilename = \
|
||||||
baseDir + '/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/.followDMs'
|
nickname + '@' + domain + '/.followDMs'
|
||||||
if os.path.isfile(followDMsFilename):
|
if os.path.isfile(followDMsFilename):
|
||||||
|
# get the file containing following handles
|
||||||
followingFilename = \
|
followingFilename = \
|
||||||
baseDir + '/accounts/' + \
|
baseDir + '/accounts/' + \
|
||||||
nickname + '@' + domain + '/following.txt'
|
nickname + '@' + domain + '/following.txt'
|
||||||
|
# who is sending a DM?
|
||||||
if not postJsonObject.get('actor'):
|
if not postJsonObject.get('actor'):
|
||||||
return False
|
return False
|
||||||
sendingActor = postJsonObject['actor']
|
sendingActor = postJsonObject['actor']
|
||||||
sendingActorNickname = \
|
sendingActorNickname = \
|
||||||
getNicknameFromActor(sendingActor)
|
getNicknameFromActor(sendingActor)
|
||||||
|
if not sendingActorNickname:
|
||||||
|
return False
|
||||||
sendingActorDomain, sendingActorPort = \
|
sendingActorDomain, sendingActorPort = \
|
||||||
getDomainFromActor(sendingActor)
|
getDomainFromActor(sendingActor)
|
||||||
if sendingActorNickname and sendingActorDomain:
|
if not sendingActorDomain:
|
||||||
if not os.path.isfile(followingFilename):
|
|
||||||
print('No following.txt file exists for ' +
|
|
||||||
nickname + '@' + domain +
|
|
||||||
' so not accepting DM from ' +
|
|
||||||
sendingActorNickname + '@' +
|
|
||||||
sendingActorDomain)
|
|
||||||
return False
|
|
||||||
sendH = \
|
|
||||||
sendingActorNickname + '@' + sendingActorDomain
|
|
||||||
if sendH != nickname + '@' + domain:
|
|
||||||
if not isFollowingActor(baseDir,
|
|
||||||
nickname, domain,
|
|
||||||
sendH):
|
|
||||||
print(nickname + '@' + domain +
|
|
||||||
' cannot receive DM from ' +
|
|
||||||
sendH +
|
|
||||||
' because they do not ' +
|
|
||||||
'follow them')
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
# check that the following file exists
|
||||||
|
if not os.path.isfile(followingFilename):
|
||||||
|
print('No following.txt file exists for ' +
|
||||||
|
nickname + '@' + domain +
|
||||||
|
' so not accepting DM from ' +
|
||||||
|
sendingActorNickname + '@' +
|
||||||
|
sendingActorDomain)
|
||||||
|
return False
|
||||||
|
# get the handle of the DM sender
|
||||||
|
sendH = \
|
||||||
|
sendingActorNickname + '@' + sendingActorDomain
|
||||||
|
# Not sending to yourself
|
||||||
|
if sendH != nickname + '@' + domain:
|
||||||
|
# check the follow
|
||||||
|
if not isFollowingActor(baseDir,
|
||||||
|
nickname, domain,
|
||||||
|
sendH):
|
||||||
|
print(nickname + '@' + domain +
|
||||||
|
' cannot receive DM from ' +
|
||||||
|
sendH +
|
||||||
|
' because they do not ' +
|
||||||
|
'follow them')
|
||||||
|
return False
|
||||||
|
|
||||||
# dm index will be updated
|
# dm index will be updated
|
||||||
updateIndexList.append('dm')
|
updateIndexList.append('dm')
|
||||||
_dmNotify(baseDir, handle,
|
_dmNotify(baseDir, handle,
|
||||||
|
|
Loading…
Reference in New Issue