merge-requests/30/head
Bob Mottram 2021-02-24 10:05:30 +00:00
parent 99035b1b7b
commit 4555917eeb
1 changed files with 31 additions and 21 deletions

View File

@ -2263,21 +2263,29 @@ 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:
return False
# check that the following file exists
if not os.path.isfile(followingFilename): if not os.path.isfile(followingFilename):
print('No following.txt file exists for ' + print('No following.txt file exists for ' +
nickname + '@' + domain + nickname + '@' + domain +
@ -2285,9 +2293,12 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
sendingActorNickname + '@' + sendingActorNickname + '@' +
sendingActorDomain) sendingActorDomain)
return False return False
# get the handle of the DM sender
sendH = \ sendH = \
sendingActorNickname + '@' + sendingActorDomain sendingActorNickname + '@' + sendingActorDomain
# Not sending to yourself
if sendH != nickname + '@' + domain: if sendH != nickname + '@' + domain:
# check the follow
if not isFollowingActor(baseDir, if not isFollowingActor(baseDir,
nickname, domain, nickname, domain,
sendH): sendH):
@ -2297,8 +2308,7 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
' because they do not ' + ' because they do not ' +
'follow them') 'follow them')
return False return False
else:
return False
# dm index will be updated # dm index will be updated
updateIndexList.append('dm') updateIndexList.append('dm')
_dmNotify(baseDir, handle, _dmNotify(baseDir, handle,