Check for sending to self

merge-requests/30/head
Bob Mottram 2021-03-07 15:29:08 +00:00
parent a1af245f2d
commit 6d66bbf9ed
1 changed files with 17 additions and 11 deletions

View File

@ -2379,19 +2379,21 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
getDomainFromActor(sendingActor) getDomainFromActor(sendingActor)
if not sendingActorDomain: if not sendingActorDomain:
return False return False
sendingToSelf = False
if sendingActorNickname == nickname and \
sendingActorDomain == domain:
sendingToSelf = True
# check that the following file exists # check that the following file exists
if not os.path.isfile(followingFilename): if not sendingToSelf:
print('No following.txt file exists for ' + if not os.path.isfile(followingFilename):
nickname + '@' + domain + print('No following.txt file exists for ' +
' so not accepting DM from ' + nickname + '@' + domain +
sendingActorNickname + '@' + ' so not accepting DM from ' +
sendingActorDomain) sendingActorNickname + '@' +
return False sendingActorDomain)
# get the handle of the DM sender return False
sendH = \
sendingActorNickname + '@' + sendingActorDomain
# Not sending to yourself # Not sending to yourself
if sendH != nickname + '@' + domain: if not sendingToSelf:
# check the follow # check the follow
if not isFollowingActor(baseDir, if not isFollowingActor(baseDir,
nickname, domain, nickname, domain,
@ -2406,6 +2408,10 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
if not obj.get('inReplyTo'): if not obj.get('inReplyTo'):
senderPostId = \ senderPostId = \
postJsonObject['id'] postJsonObject['id']
# get the handle of the DM sender
sendH = \
sendingActorNickname + \
'@' + sendingActorDomain
_bounceDM(senderPostId, _bounceDM(senderPostId,
session, httpPrefix, session, httpPrefix,
baseDir, baseDir,