diff --git a/daemon.py b/daemon.py index 3e4b362df..d89edd841 100644 --- a/daemon.py +++ b/daemon.py @@ -87,7 +87,7 @@ from inbox import populateReplies from inbox import getPersonPubKey from follow import getFollowingFeed from follow import sendFollowRequest -from follow import unfollowPerson +from follow import unfollowAccount from follow import createInitialLastSeen from auth import authorize from auth import createPassword @@ -2115,9 +2115,9 @@ class PubServer(BaseHTTPRequestHandler): } pathUsersSection = path.split('/users/')[1] self.postToNickname = pathUsersSection.split('/')[0] - unfollowPerson(self.server.baseDir, self.postToNickname, - self.server.domain, - followingNickname, followingDomainFull) + unfollowAccount(self.server.baseDir, self.postToNickname, + self.server.domain, + followingNickname, followingDomainFull) self._postToOutboxThread(unfollowJson) if callingDomain.endswith('.onion') and onionDomain: diff --git a/follow.py b/follow.py index 441d02fdf..2a765b15e 100644 --- a/follow.py +++ b/follow.py @@ -212,10 +212,10 @@ def isFollowerOfPerson(baseDir: str, nickname: str, domain: str, return alreadyFollowing -def unfollowPerson(baseDir: str, nickname: str, domain: str, - followNickname: str, followDomain: str, - followFile='following.txt', - debug=False) -> bool: +def unfollowAccount(baseDir: str, nickname: str, domain: str, + followNickname: str, followDomain: str, + followFile='following.txt', + debug=False) -> bool: """Removes a person to the follow list """ if ':' in domain: @@ -261,14 +261,14 @@ def unfollowPerson(baseDir: str, nickname: str, domain: str, return True -def unfollowerOfPerson(baseDir: str, nickname: str, domain: str, - followerNickname: str, followerDomain: str, - debug=False) -> bool: +def unfollowerOfAccount(baseDir: str, nickname: str, domain: str, + followerNickname: str, followerDomain: str, + debug=False) -> bool: """Remove a follower of a person """ - return unfollowPerson(baseDir, nickname, domain, - followerNickname, followerDomain, - 'followers.txt', debug) + return unfollowAccount(baseDir, nickname, domain, + followerNickname, followerDomain, + 'followers.txt', debug) def clearFollows(baseDir: str, nickname: str, domain: str, @@ -1208,8 +1208,8 @@ def outboxUndoFollow(baseDir: str, messageJson: {}, debug: bool) -> None: getDomainFromActor(messageJson['object']['object']) domainFollowingFull = getFullDomain(domainFollowing, portFollowing) - if unfollowPerson(baseDir, nicknameFollower, domainFollowerFull, - nicknameFollowing, domainFollowingFull): + if unfollowAccount(baseDir, nicknameFollower, domainFollowerFull, + nicknameFollowing, domainFollowingFull): if debug: print('DEBUG: ' + nicknameFollower + ' unfollowed ' + nicknameFollowing + '@' + domainFollowingFull) diff --git a/inbox.py b/inbox.py index 50722c2d5..7be1f1a4d 100644 --- a/inbox.py +++ b/inbox.py @@ -39,7 +39,7 @@ from session import createSession from session import getJson from follow import receiveFollowRequest from follow import getFollowersOfActor -from follow import unfollowerOfPerson +from follow import unfollowerOfAccount from pprint import pprint from cache import getPersonFromCache from cache import storePersonInCache @@ -49,8 +49,8 @@ from bookmarks import undoBookmarksCollectionEntry from blocking import isBlocked from blocking import isBlockedDomain from filters import isFiltered -from announce import updateAnnounceCollection -from announce import undoAnnounceCollectionEntry +from utils import updateAnnounceCollection +from utils import undoAnnounceCollectionEntry from httpsig import messageContentDigest from posts import validContentWarning from posts import downloadAnnounce @@ -637,10 +637,10 @@ def receiveUndoFollow(session, baseDir: str, httpPrefix: str, getDomainFromActor(messageJson['object']['object']) domainFollowingFull = getFullDomain(domainFollowing, portFollowing) - if unfollowerOfPerson(baseDir, - nicknameFollowing, domainFollowingFull, - nicknameFollower, domainFollowerFull, - debug): + if unfollowerOfAccount(baseDir, + nicknameFollowing, domainFollowingFull, + nicknameFollower, domainFollowerFull, + debug): print(nicknameFollowing + '@' + domainFollowingFull + ': ' 'Follower ' + nicknameFollower + '@' + domainFollowerFull + ' was removed') diff --git a/tests.py b/tests.py index edf17efaa..461d03323 100644 --- a/tests.py +++ b/tests.py @@ -49,8 +49,8 @@ from utils import getStatusNumber from utils import getFollowersOfPerson from utils import removeHtml from follow import followerOfPerson -from follow import unfollowPerson -from follow import unfollowerOfPerson +from follow import unfollowAccount +from follow import unfollowerOfAccount from follow import sendFollowRequest from person import createPerson from person import setDisplayNickname @@ -73,7 +73,7 @@ from delete import sendDeleteViaServer from inbox import jsonPostAllowsComments from inbox import validInbox from inbox import validInboxFilenames -from inbox import guessHashtagCategory +from categories import guessHashtagCategory from content import htmlReplaceEmailQuote from content import htmlReplaceQuoteMarks from content import dangerousMarkup @@ -978,7 +978,7 @@ def testNoOfFollowersOnDomain(): noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain) assert followersOnOtherDomain == 3 - unfollowerOfPerson(baseDir, nickname, domain, 'sausagedog', otherdomain) + unfollowerOfAccount(baseDir, nickname, domain, 'sausagedog', otherdomain) followersOnOtherDomain = \ noOfFollowersOnDomain(baseDir, nickname + '@' + domain, otherdomain) assert followersOnOtherDomain == 2 @@ -1074,7 +1074,7 @@ def testFollows(): assert(False) assert(domainFound) - unfollowPerson(baseDir, nickname, domain, 'batman', 'mesh.com') + unfollowAccount(baseDir, nickname, domain, 'batman', 'mesh.com') domainFound = False for followingDomain in f: @@ -2614,6 +2614,9 @@ def testFunctions(): 'E2EEremoveDevice', 'setOrganizationScheme' ] + excludeImports = [ + 'link' + ] # check that functions are called somewhere for name, properties in functionProperties.items(): if name in exclusions: @@ -2623,6 +2626,14 @@ def testFunctions(): ' in module ' + properties['module'] + ' is not called anywhere') assert properties['calledInModule'] + if name not in excludeImports: + for modName in properties['calledInModule']: + if modName == properties['module']: + continue + importStr = 'from ' + properties['module'] + ' import ' + name + if importStr not in open(modName + '.py').read(): + print(importStr + ' not found in ' + modName + '.py') + assert False print('Function: ' + name + ' ✓') # print(str(function)) # print(str(functionProperties))