mirror of https://gitlab.com/bashrc2/epicyon
Improve follow checking when a DM arrives
parent
94b666d803
commit
764f6673c0
|
@ -126,6 +126,7 @@ def _removeFromFollowRejects(baseDir: str,
|
|||
def isFollowingActor(baseDir: str,
|
||||
nickname: str, domain: str, actor: str) -> bool:
|
||||
"""Is the given nickname following the given actor?
|
||||
The actor can also be a handle: nickname@domain
|
||||
"""
|
||||
if ':' in domain:
|
||||
domain = domain.split(':')[0]
|
||||
|
@ -137,6 +138,12 @@ def isFollowingActor(baseDir: str,
|
|||
return False
|
||||
if actor.lower() in open(followingFile).read().lower():
|
||||
return True
|
||||
if '@' in actor and '://' not in actor:
|
||||
# the actor is a handle: nickname@domain
|
||||
followingHandle = actor.lower()
|
||||
if followingHandle in open(followingFile).read().lower():
|
||||
return True
|
||||
return False
|
||||
followingNickname = getNicknameFromActor(actor)
|
||||
if not followingNickname:
|
||||
print('WARN: unable to find nickname in ' + actor)
|
||||
|
|
7
inbox.py
7
inbox.py
|
@ -40,6 +40,7 @@ from categories import setHashtagCategory
|
|||
from httpsig import verifyPostHeaders
|
||||
from session import createSession
|
||||
from session import getJson
|
||||
from follow import isFollowingActor
|
||||
from follow import receiveFollowRequest
|
||||
from follow import getFollowersOfActor
|
||||
from follow import unfollowerOfAccount
|
||||
|
@ -73,7 +74,6 @@ from git import receiveGitPatch
|
|||
from followingCalendar import receivingCalendarEvents
|
||||
from happening import saveEventPost
|
||||
from delete import removeOldHashtags
|
||||
from follow import isFollowingActor
|
||||
from categories import guessHashtagCategory
|
||||
from context import hasValidContext
|
||||
|
||||
|
@ -2288,8 +2288,9 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
sendH = \
|
||||
sendingActorNickname + '@' + sendingActorDomain
|
||||
if sendH != nickname + '@' + domain:
|
||||
if sendH not in \
|
||||
open(followingFilename).read():
|
||||
if not isFollowingActor(baseDir,
|
||||
nickname, domain,
|
||||
sendH):
|
||||
print(nickname + '@' + domain +
|
||||
' cannot receive DM from ' +
|
||||
sendH +
|
||||
|
|
Loading…
Reference in New Issue