mirror of https://gitlab.com/bashrc2/epicyon
Unfollowing group handles
parent
3f14bc178c
commit
71cabd74a2
|
@ -17,6 +17,7 @@ from utils import domainPermitted
|
||||||
from utils import followPerson
|
from utils import followPerson
|
||||||
from utils import hasObjectDict
|
from utils import hasObjectDict
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from utils import hasGroupPath
|
||||||
|
|
||||||
|
|
||||||
def _createAcceptReject(baseDir: str, federationList: [],
|
def _createAcceptReject(baseDir: str, federationList: [],
|
||||||
|
@ -160,10 +161,13 @@ def _acceptFollow(baseDir: str, domain: str, messageJson: {},
|
||||||
' but they have been unfollowed')
|
' but they have been unfollowed')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# does the url path indicate that this is a group actor
|
||||||
|
groupAccount = hasGroupPath(followedActor)
|
||||||
|
|
||||||
if followPerson(baseDir,
|
if followPerson(baseDir,
|
||||||
nickname, acceptedDomainFull,
|
nickname, acceptedDomainFull,
|
||||||
followedNickname, followedDomainFull,
|
followedNickname, followedDomainFull,
|
||||||
federationList, debug):
|
federationList, debug, groupAccount):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: ' + nickname + '@' + acceptedDomainFull +
|
print('DEBUG: ' + nickname + '@' + acceptedDomainFull +
|
||||||
' followed ' + followedNickname + '@' + followedDomainFull)
|
' followed ' + followedNickname + '@' + followedDomainFull)
|
||||||
|
|
|
@ -273,6 +273,7 @@ from utils import isSuspended
|
||||||
from utils import dangerousMarkup
|
from utils import dangerousMarkup
|
||||||
from utils import refreshNewswire
|
from utils import refreshNewswire
|
||||||
from utils import isImageFile
|
from utils import isImageFile
|
||||||
|
from utils import hasGroupPath
|
||||||
from manualapprove import manualDenyFollowRequest
|
from manualapprove import manualDenyFollowRequest
|
||||||
from manualapprove import manualApproveFollowRequest
|
from manualapprove import manualApproveFollowRequest
|
||||||
from announce import createAnnounce
|
from announce import createAnnounce
|
||||||
|
@ -2568,9 +2569,11 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
}
|
}
|
||||||
pathUsersSection = path.split('/users/')[1]
|
pathUsersSection = path.split('/users/')[1]
|
||||||
self.postToNickname = pathUsersSection.split('/')[0]
|
self.postToNickname = pathUsersSection.split('/')[0]
|
||||||
|
groupAccount = hasGroupPath(followingActor)
|
||||||
unfollowAccount(self.server.baseDir, self.postToNickname,
|
unfollowAccount(self.server.baseDir, self.postToNickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
followingNickname, followingDomainFull)
|
followingNickname, followingDomainFull,
|
||||||
|
self.server.debug, groupAccount)
|
||||||
self._postToOutboxThread(unfollowJson)
|
self._postToOutboxThread(unfollowJson)
|
||||||
|
|
||||||
if callingDomain.endswith('.onion') and onionDomain:
|
if callingDomain.endswith('.onion') and onionDomain:
|
||||||
|
|
12
epicyon.py
12
epicyon.py
|
@ -2499,17 +2499,17 @@ if args.testdata:
|
||||||
domainFull = domain + ':' + str(port)
|
domainFull = domain + ':' + str(port)
|
||||||
clearFollows(baseDir, nickname, domain)
|
clearFollows(baseDir, nickname, domain)
|
||||||
followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'ultrapancake', domainFull,
|
followPerson(baseDir, nickname, domain, 'ultrapancake', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'sausagedog', domainFull,
|
followPerson(baseDir, nickname, domain, 'sausagedog', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'drokk', domainFull,
|
followPerson(baseDir, nickname, domain, 'drokk', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'drokk', domainFull,
|
followerOfPerson(baseDir, nickname, domain, 'drokk', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
followerOfPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
setConfigParam(baseDir, 'admin', nickname)
|
setConfigParam(baseDir, 'admin', nickname)
|
||||||
|
|
||||||
# set a lower bound to the maximum mentions
|
# set a lower bound to the maximum mentions
|
||||||
|
|
27
follow.py
27
follow.py
|
@ -28,6 +28,7 @@ from utils import saveJson
|
||||||
from utils import isAccountDir
|
from utils import isAccountDir
|
||||||
from utils import getUserPaths
|
from utils import getUserPaths
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from utils import hasGroupPath
|
||||||
from acceptreject import createAccept
|
from acceptreject import createAccept
|
||||||
from acceptreject import createReject
|
from acceptreject import createReject
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -62,6 +63,8 @@ def createInitialLastSeen(baseDir: str, httpPrefix: str) -> None:
|
||||||
handle = handle.replace('\n', '')
|
handle = handle.replace('\n', '')
|
||||||
nickname = handle.split('@')[0]
|
nickname = handle.split('@')[0]
|
||||||
domain = handle.split('@')[1]
|
domain = handle.split('@')[1]
|
||||||
|
if nickname.startswith('!'):
|
||||||
|
nickname = nickname[1:]
|
||||||
actor = \
|
actor = \
|
||||||
httpPrefix + '://' + domain + '/users/' + nickname
|
httpPrefix + '://' + domain + '/users/' + nickname
|
||||||
lastSeenFilename = \
|
lastSeenFilename = \
|
||||||
|
@ -194,12 +197,13 @@ def getMutualsOfPerson(baseDir: str,
|
||||||
|
|
||||||
def followerOfPerson(baseDir: str, nickname: str, domain: str,
|
def followerOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
followerNickname: str, followerDomain: str,
|
followerNickname: str, followerDomain: str,
|
||||||
federationList: [], debug: bool) -> bool:
|
federationList: [], debug: bool,
|
||||||
|
groupAccount: bool) -> bool:
|
||||||
"""Adds a follower of the given person
|
"""Adds a follower of the given person
|
||||||
"""
|
"""
|
||||||
return followPerson(baseDir, nickname, domain,
|
return followPerson(baseDir, nickname, domain,
|
||||||
followerNickname, followerDomain,
|
followerNickname, followerDomain,
|
||||||
federationList, debug, 'followers.txt')
|
federationList, debug, groupAccount, 'followers.txt')
|
||||||
|
|
||||||
|
|
||||||
def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -233,13 +237,15 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
followNickname: str, followDomain: str,
|
followNickname: str, followDomain: str,
|
||||||
followFile: str = 'following.txt',
|
debug: bool, groupAccount: bool,
|
||||||
debug: bool = False) -> bool:
|
followFile: str = 'following.txt') -> bool:
|
||||||
"""Removes a person to the follow list
|
"""Removes a person to the follow list
|
||||||
"""
|
"""
|
||||||
domain = removeDomainPort(domain)
|
domain = removeDomainPort(domain)
|
||||||
handle = nickname + '@' + domain
|
handle = nickname + '@' + domain
|
||||||
handleToUnfollow = followNickname + '@' + followDomain
|
handleToUnfollow = followNickname + '@' + followDomain
|
||||||
|
if groupAccount:
|
||||||
|
handleToUnfollow = '!' + handleToUnfollow
|
||||||
if not os.path.isdir(baseDir + '/accounts'):
|
if not os.path.isdir(baseDir + '/accounts'):
|
||||||
os.mkdir(baseDir + '/accounts')
|
os.mkdir(baseDir + '/accounts')
|
||||||
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
if not os.path.isdir(baseDir + '/accounts/' + handle):
|
||||||
|
@ -260,8 +266,9 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
with open(filename, 'w+') as f:
|
with open(filename, 'w+') as f:
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.strip("\n").strip("\r").lower() != \
|
checkHandle = line.strip("\n").strip("\r").lower()
|
||||||
handleToUnfollowLower:
|
if checkHandle != handleToUnfollowLower and \
|
||||||
|
checkHandle != '!' + handleToUnfollowLower:
|
||||||
f.write(line)
|
f.write(line)
|
||||||
|
|
||||||
# write to an unfollowed file so that if a follow accept
|
# write to an unfollowed file so that if a follow accept
|
||||||
|
@ -281,12 +288,12 @@ def unfollowAccount(baseDir: str, nickname: str, domain: str,
|
||||||
|
|
||||||
def unfollowerOfAccount(baseDir: str, nickname: str, domain: str,
|
def unfollowerOfAccount(baseDir: str, nickname: str, domain: str,
|
||||||
followerNickname: str, followerDomain: str,
|
followerNickname: str, followerDomain: str,
|
||||||
debug: bool = False) -> bool:
|
debug: bool, groupAccount: bool) -> bool:
|
||||||
"""Remove a follower of a person
|
"""Remove a follower of a person
|
||||||
"""
|
"""
|
||||||
return unfollowAccount(baseDir, nickname, domain,
|
return unfollowAccount(baseDir, nickname, domain,
|
||||||
followerNickname, followerDomain,
|
followerNickname, followerDomain,
|
||||||
'followers.txt', debug)
|
debug, groupAccount, 'followers.txt')
|
||||||
|
|
||||||
|
|
||||||
def clearFollows(baseDir: str, nickname: str, domain: str,
|
def clearFollows(baseDir: str, nickname: str, domain: str,
|
||||||
|
@ -1418,8 +1425,10 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None:
|
||||||
getDomainFromActor(messageJson['object']['object'])
|
getDomainFromActor(messageJson['object']['object'])
|
||||||
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
|
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
|
||||||
|
|
||||||
|
groupAccount = hasGroupPath(messageJson['object']['object'])
|
||||||
if unfollowAccount(baseDir, nicknameFollower, domainFollowerFull,
|
if unfollowAccount(baseDir, nicknameFollower, domainFollowerFull,
|
||||||
nicknameFollowing, domainFollowingFull):
|
nicknameFollowing, domainFollowingFull,
|
||||||
|
debug, groupAccount):
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: ' + nicknameFollower + ' unfollowed ' +
|
print('DEBUG: ' + nicknameFollower + ' unfollowed ' +
|
||||||
nicknameFollowing + '@' + domainFollowingFull)
|
nicknameFollowing + '@' + domainFollowingFull)
|
||||||
|
|
4
inbox.py
4
inbox.py
|
@ -45,6 +45,7 @@ from utils import loadJson
|
||||||
from utils import saveJson
|
from utils import saveJson
|
||||||
from utils import updateLikesCollection
|
from utils import updateLikesCollection
|
||||||
from utils import undoLikesCollectionEntry
|
from utils import undoLikesCollectionEntry
|
||||||
|
from utils import hasGroupPath
|
||||||
from categories import getHashtagCategories
|
from categories import getHashtagCategories
|
||||||
from categories import setHashtagCategory
|
from categories import setHashtagCategory
|
||||||
from httpsig import verifyPostHeaders
|
from httpsig import verifyPostHeaders
|
||||||
|
@ -675,10 +676,11 @@ def _receiveUndoFollow(session, baseDir: str, httpPrefix: str,
|
||||||
getDomainFromActor(messageJson['object']['object'])
|
getDomainFromActor(messageJson['object']['object'])
|
||||||
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
|
domainFollowingFull = getFullDomain(domainFollowing, portFollowing)
|
||||||
|
|
||||||
|
groupAccount = hasGroupPath(messageJson['object']['actor'])
|
||||||
if unfollowerOfAccount(baseDir,
|
if unfollowerOfAccount(baseDir,
|
||||||
nicknameFollowing, domainFollowingFull,
|
nicknameFollowing, domainFollowingFull,
|
||||||
nicknameFollower, domainFollowerFull,
|
nicknameFollower, domainFollowerFull,
|
||||||
debug):
|
debug, groupAccount):
|
||||||
print(nicknameFollowing + '@' + domainFollowingFull + ': '
|
print(nicknameFollowing + '@' + domainFollowingFull + ': '
|
||||||
'Follower ' + nicknameFollower + '@' + domainFollowerFull +
|
'Follower ' + nicknameFollower + '@' + domainFollowerFull +
|
||||||
' was removed')
|
' was removed')
|
||||||
|
|
|
@ -12,6 +12,7 @@ from utils import isAccountDir
|
||||||
from utils import getNicknameFromActor
|
from utils import getNicknameFromActor
|
||||||
from utils import getDomainFromActor
|
from utils import getDomainFromActor
|
||||||
from utils import acctDir
|
from utils import acctDir
|
||||||
|
from utils import hasGroupPath
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
from posts import getUserUrl
|
from posts import getUserUrl
|
||||||
|
@ -102,13 +103,14 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
if movedToPort:
|
if movedToPort:
|
||||||
if movedToPort != 80 and movedToPort != 443:
|
if movedToPort != 80 and movedToPort != 443:
|
||||||
movedToDomainFull = movedToDomain + ':' + str(movedToPort)
|
movedToDomainFull = movedToDomain + ':' + str(movedToPort)
|
||||||
|
groupAccount = hasGroupPath(movedToUrl)
|
||||||
if isBlocked(baseDir, nickname, domain,
|
if isBlocked(baseDir, nickname, domain,
|
||||||
movedToNickname, movedToDomain):
|
movedToNickname, movedToDomain):
|
||||||
# someone that you follow has moved to a blocked domain
|
# someone that you follow has moved to a blocked domain
|
||||||
# so just unfollow them
|
# so just unfollow them
|
||||||
unfollowAccount(baseDir, nickname, domain,
|
unfollowAccount(baseDir, nickname, domain,
|
||||||
movedToNickname, movedToDomainFull,
|
movedToNickname, movedToDomainFull,
|
||||||
'following.txt', debug)
|
debug, groupAccount, 'following.txt')
|
||||||
return ctr
|
return ctr
|
||||||
|
|
||||||
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
followingFilename = acctDir(baseDir, nickname, domain) + '/following.txt'
|
||||||
|
@ -134,7 +136,7 @@ def _updateMovedHandle(baseDir: str, nickname: str, domain: str,
|
||||||
unfollowAccount(baseDir, nickname, domain,
|
unfollowAccount(baseDir, nickname, domain,
|
||||||
handleNickname,
|
handleNickname,
|
||||||
handleDomain,
|
handleDomain,
|
||||||
'following.txt', debug)
|
debug, groupAccount, 'following.txt')
|
||||||
ctr += 1
|
ctr += 1
|
||||||
print('Unfollowed ' + handle + ' who has moved to ' +
|
print('Unfollowed ' + handle + ' who has moved to ' +
|
||||||
movedToHandle)
|
movedToHandle)
|
||||||
|
|
80
tests.py
80
tests.py
|
@ -483,9 +483,9 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
assert setRole(path, nickname, domain, 'guru')
|
assert setRole(path, nickname, domain, 'guru')
|
||||||
if hasFollows:
|
if hasFollows:
|
||||||
followPerson(path, nickname, domain, 'bob', bobAddress,
|
followPerson(path, nickname, domain, 'bob', bobAddress,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
|
followerOfPerson(path, nickname, domain, 'bob', bobAddress,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
if hasPosts:
|
if hasPosts:
|
||||||
testFollowersOnly = False
|
testFollowersOnly = False
|
||||||
testSaveToFile = True
|
testSaveToFile = True
|
||||||
|
@ -612,9 +612,9 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
deleteAllPosts(path, nickname, domain, 'outbox')
|
deleteAllPosts(path, nickname, domain, 'outbox')
|
||||||
if hasFollows:
|
if hasFollows:
|
||||||
followPerson(path, nickname, domain,
|
followPerson(path, nickname, domain,
|
||||||
'alice', aliceAddress, federationList, False)
|
'alice', aliceAddress, federationList, False, False)
|
||||||
followerOfPerson(path, nickname, domain,
|
followerOfPerson(path, nickname, domain,
|
||||||
'alice', aliceAddress, federationList, False)
|
'alice', aliceAddress, federationList, False, False)
|
||||||
if hasPosts:
|
if hasPosts:
|
||||||
testFollowersOnly = False
|
testFollowersOnly = False
|
||||||
testSaveToFile = True
|
testSaveToFile = True
|
||||||
|
@ -967,10 +967,10 @@ def testPostMessageBetweenServers():
|
||||||
|
|
||||||
aliceDomainStr = aliceDomain + ':' + str(alicePort)
|
aliceDomainStr = aliceDomain + ':' + str(alicePort)
|
||||||
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
|
followerOfPerson(bobDir, 'bob', bobDomain, 'alice',
|
||||||
aliceDomainStr, federationList, False)
|
aliceDomainStr, federationList, False, False)
|
||||||
bobDomainStr = bobDomain + ':' + str(bobPort)
|
bobDomainStr = bobDomain + ':' + str(bobPort)
|
||||||
followPerson(aliceDir, 'alice', aliceDomain, 'bob',
|
followPerson(aliceDir, 'alice', aliceDomain, 'bob',
|
||||||
bobDomainStr, federationList, False)
|
bobDomainStr, federationList, False, False)
|
||||||
|
|
||||||
sessionBob = createSession(proxyType)
|
sessionBob = createSession(proxyType)
|
||||||
bobPostLog = []
|
bobPostLog = []
|
||||||
|
@ -1273,18 +1273,18 @@ def _testFollowersOfPerson():
|
||||||
|
|
||||||
clearFollows(baseDir, nickname, domain)
|
clearFollows(baseDir, nickname, domain)
|
||||||
followPerson(baseDir, nickname, domain, 'maxboardroom', domain,
|
followPerson(baseDir, nickname, domain, 'maxboardroom', domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, 'drokk', domain, 'ultrapancake', domain,
|
followPerson(baseDir, 'drokk', domain, 'ultrapancake', domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
# deliberate duplication
|
# deliberate duplication
|
||||||
followPerson(baseDir, 'drokk', domain, 'ultrapancake', domain,
|
followPerson(baseDir, 'drokk', domain, 'ultrapancake', domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, 'sausagedog', domain, 'ultrapancake', domain,
|
followPerson(baseDir, 'sausagedog', domain, 'ultrapancake', domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'ultrapancake', domain,
|
followPerson(baseDir, nickname, domain, 'ultrapancake', domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'someother', 'randodomain.net',
|
followPerson(baseDir, nickname, domain, 'someother', 'randodomain.net',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
followList = getFollowersOfPerson(baseDir, 'ultrapancake', domain)
|
followList = getFollowersOfPerson(baseDir, 'ultrapancake', domain)
|
||||||
assert len(followList) == 3
|
assert len(followList) == 3
|
||||||
|
@ -1322,32 +1322,33 @@ def _testNoOfFollowersOnDomain():
|
||||||
httpPrefix, True, False, password)
|
httpPrefix, True, False, password)
|
||||||
|
|
||||||
followPerson(baseDir, 'drokk', otherdomain, nickname, domain,
|
followPerson(baseDir, 'drokk', otherdomain, nickname, domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, 'sausagedog', otherdomain, nickname, domain,
|
followPerson(baseDir, 'sausagedog', otherdomain, nickname, domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, 'maxboardroom', otherdomain, nickname, domain,
|
followPerson(baseDir, 'maxboardroom', otherdomain, nickname, domain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
followerOfPerson(baseDir, nickname, domain,
|
followerOfPerson(baseDir, nickname, domain,
|
||||||
'cucumber', 'sandwiches.party',
|
'cucumber', 'sandwiches.party',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain,
|
followerOfPerson(baseDir, nickname, domain,
|
||||||
'captainsensible', 'damned.zone',
|
'captainsensible', 'damned.zone',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'pilchard', 'zombies.attack',
|
followerOfPerson(baseDir, nickname, domain, 'pilchard', 'zombies.attack',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'drokk', otherdomain,
|
followerOfPerson(baseDir, nickname, domain, 'drokk', otherdomain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'sausagedog', otherdomain,
|
followerOfPerson(baseDir, nickname, domain, 'sausagedog', otherdomain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'maxboardroom', otherdomain,
|
followerOfPerson(baseDir, nickname, domain, 'maxboardroom', otherdomain,
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
followersOnOtherDomain = \
|
followersOnOtherDomain = \
|
||||||
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
|
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
|
||||||
assert followersOnOtherDomain == 3
|
assert followersOnOtherDomain == 3
|
||||||
|
|
||||||
unfollowerOfAccount(baseDir, nickname, domain, 'sausagedog', otherdomain)
|
unfollowerOfAccount(baseDir, nickname, domain, 'sausagedog', otherdomain,
|
||||||
|
False, False)
|
||||||
followersOnOtherDomain = \
|
followersOnOtherDomain = \
|
||||||
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
|
noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain)
|
||||||
assert followersOnOtherDomain == 2
|
assert followersOnOtherDomain == 2
|
||||||
|
@ -1376,17 +1377,17 @@ def _testGroupFollowers():
|
||||||
|
|
||||||
clearFollowers(baseDir, nickname, domain)
|
clearFollowers(baseDir, nickname, domain)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'badger', 'wild.domain',
|
followerOfPerson(baseDir, nickname, domain, 'badger', 'wild.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'squirrel', 'wild.domain',
|
followerOfPerson(baseDir, nickname, domain, 'squirrel', 'wild.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'rodent', 'wild.domain',
|
followerOfPerson(baseDir, nickname, domain, 'rodent', 'wild.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'utterly', 'clutterly.domain',
|
followerOfPerson(baseDir, nickname, domain, 'utterly', 'clutterly.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'zonked', 'zzz.domain',
|
followerOfPerson(baseDir, nickname, domain, 'zonked', 'zzz.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'nap', 'zzz.domain',
|
followerOfPerson(baseDir, nickname, domain, 'nap', 'zzz.domain',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
grouped = groupFollowersByDomain(baseDir, nickname, domain)
|
grouped = groupFollowersByDomain(baseDir, nickname, domain)
|
||||||
assert len(grouped.items()) == 3
|
assert len(grouped.items()) == 3
|
||||||
|
@ -1420,15 +1421,15 @@ def _testFollows():
|
||||||
|
|
||||||
clearFollows(baseDir, nickname, domain)
|
clearFollows(baseDir, nickname, domain)
|
||||||
followPerson(baseDir, nickname, domain, 'badger', 'wild.com',
|
followPerson(baseDir, nickname, domain, 'badger', 'wild.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'squirrel', 'secret.com',
|
followPerson(baseDir, nickname, domain, 'squirrel', 'secret.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'rodent', 'drainpipe.com',
|
followPerson(baseDir, nickname, domain, 'rodent', 'drainpipe.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'batman', 'mesh.com',
|
followPerson(baseDir, nickname, domain, 'batman', 'mesh.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
followPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
f = open(accountDir + '/following.txt', 'r')
|
f = open(accountDir + '/following.txt', 'r')
|
||||||
|
@ -1443,7 +1444,8 @@ def _testFollows():
|
||||||
assert(False)
|
assert(False)
|
||||||
|
|
||||||
assert(domainFound)
|
assert(domainFound)
|
||||||
unfollowAccount(baseDir, nickname, domain, 'batman', 'mesh.com')
|
unfollowAccount(baseDir, nickname, domain, 'batman', 'mesh.com',
|
||||||
|
True, False)
|
||||||
|
|
||||||
domainFound = False
|
domainFound = False
|
||||||
for followingDomain in f:
|
for followingDomain in f:
|
||||||
|
@ -1455,15 +1457,15 @@ def _testFollows():
|
||||||
|
|
||||||
clearFollowers(baseDir, nickname, domain)
|
clearFollowers(baseDir, nickname, domain)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'badger', 'wild.com',
|
followerOfPerson(baseDir, nickname, domain, 'badger', 'wild.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'squirrel', 'secret.com',
|
followerOfPerson(baseDir, nickname, domain, 'squirrel', 'secret.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'rodent', 'drainpipe.com',
|
followerOfPerson(baseDir, nickname, domain, 'rodent', 'drainpipe.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'batman', 'mesh.com',
|
followerOfPerson(baseDir, nickname, domain, 'batman', 'mesh.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
followerOfPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
followerOfPerson(baseDir, nickname, domain, 'giraffe', 'trees.com',
|
||||||
federationList, False)
|
federationList, False, False)
|
||||||
|
|
||||||
accountDir = acctDir(baseDir, nickname, domain)
|
accountDir = acctDir(baseDir, nickname, domain)
|
||||||
f = open(accountDir + '/followers.txt', 'r')
|
f = open(accountDir + '/followers.txt', 'r')
|
||||||
|
|
17
utils.py
17
utils.py
|
@ -983,7 +983,7 @@ def getGroupPaths() -> []:
|
||||||
"""Returns possible group paths
|
"""Returns possible group paths
|
||||||
e.g. https://lemmy/c/groupname
|
e.g. https://lemmy/c/groupname
|
||||||
"""
|
"""
|
||||||
return ('/c/')
|
return ['/c/']
|
||||||
|
|
||||||
|
|
||||||
def getDomainFromActor(actor: str) -> (str, int):
|
def getDomainFromActor(actor: str) -> (str, int):
|
||||||
|
@ -1051,7 +1051,8 @@ def _setDefaultPetName(baseDir: str, nickname: str, domain: str,
|
||||||
def followPerson(baseDir: str, nickname: str, domain: str,
|
def followPerson(baseDir: str, nickname: str, domain: str,
|
||||||
followNickname: str, followDomain: str,
|
followNickname: str, followDomain: str,
|
||||||
federationList: [], debug: bool,
|
federationList: [], debug: bool,
|
||||||
followFile='following.txt') -> bool:
|
groupAccount: bool,
|
||||||
|
followFile: str = 'following.txt') -> bool:
|
||||||
"""Adds a person to the follow list
|
"""Adds a person to the follow list
|
||||||
"""
|
"""
|
||||||
followDomainStrLower = followDomain.lower().replace('\n', '')
|
followDomainStrLower = followDomain.lower().replace('\n', '')
|
||||||
|
@ -2679,3 +2680,15 @@ def dateSecondsToString(dateSec: int) -> str:
|
||||||
"""
|
"""
|
||||||
thisDate = datetime.datetime.fromtimestamp(dateSec)
|
thisDate = datetime.datetime.fromtimestamp(dateSec)
|
||||||
return thisDate.strftime("%Y-%m-%dT%H:%M:%SZ")
|
return thisDate.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
|
||||||
|
def hasGroupPath(actor: str) -> bool:
|
||||||
|
"""Does the given actor url contain a path which indicates
|
||||||
|
that it belongs to a group?
|
||||||
|
e.g. https://lemmy/c/groupname
|
||||||
|
"""
|
||||||
|
groupPaths = getGroupPaths()
|
||||||
|
for grpPath in groupPaths:
|
||||||
|
if grpPath in actor:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue