From b3bb866f692fbb3d2a5db623136808bd5ab6f704 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 26 Dec 2020 10:22:56 +0000 Subject: [PATCH] Remove option to follow new actor It wasn't implemented, and doing so could create an oprn relay situation where the authenticity of posts becomes obscured --- daemon.py | 8 +------- epicyon.py | 11 ----------- follow.py | 29 ++++++++++------------------- inbox.py | 2 -- tests.py | 11 +++++++---- 5 files changed, 18 insertions(+), 43 deletions(-) diff --git a/daemon.py b/daemon.py index 1553440e..b21e3322 100644 --- a/daemon.py +++ b/daemon.py @@ -2237,8 +2237,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.cachedWebfingers, self.server.personCache, debug, - self.server.projectVersion, - self.server.allowNewsFollowers) + self.server.projectVersion) if callingDomain.endswith('.onion') and onionDomain: originPathStr = 'http://' + onionDomain + usersPath elif (callingDomain.endswith('.i2p') and i2pDomain): @@ -13364,7 +13363,6 @@ def runDaemon(sendThreadsTimeoutMins: int, fullWidthTimelineButtonHeader: bool, showPublishAsIcon: bool, maxFollowers: int, - allowNewsFollowers: bool, maxNewsPosts: int, maxMirroredArticles: int, maxNewswireFeedSizeKb: int, @@ -13515,9 +13513,6 @@ def runDaemon(sendThreadsTimeoutMins: int, # maximum number of posts in the news timeline/outbox httpd.maxNewsPosts = maxNewsPosts - # whether or not to allow followers of the news account - httpd.allowNewsFollowers = allowNewsFollowers - # The maximum number of tags per post which can be # attached to RSS feeds pulled in via the newswire httpd.maxTags = 32 @@ -13704,7 +13699,6 @@ def runDaemon(sendThreadsTimeoutMins: int, httpd.translate, unitTest, httpd.YTReplacementDomain, httpd.showPublishedDateOnly, - httpd.allowNewsFollowers, httpd.maxFollowers, httpd.allowLocalNetworkAccess, httpd.peertubeInstances), daemon=True) diff --git a/epicyon.py b/epicyon.py index 3c111e4b..a8d25be4 100644 --- a/epicyon.py +++ b/epicyon.py @@ -243,11 +243,6 @@ parser.add_argument("--fullWidthTimelineButtonHeader", help="Whether to show the timeline " + "button header containing inbox and outbox " + "as the full width of the screen") -parser.add_argument("--allowNewsFollowers", - dest='allowNewsFollowers', - type=str2bool, nargs='?', - const=True, default=False, - help="Whether to allow the news account to be followed") parser.add_argument("--iconsAsButtons", dest='iconsAsButtons', type=str2bool, nargs='?', @@ -2095,11 +2090,6 @@ sendThreadsTimeoutMins = \ if sendThreadsTimeoutMins is not None: args.sendThreadsTimeoutMins = int(sendThreadsTimeoutMins) -allowNewsFollowers = \ - getConfigParam(baseDir, 'allowNewsFollowers') -if allowNewsFollowers is not None: - args.allowNewsFollowers = bool(allowNewsFollowers) - showPublishAsIcon = \ getConfigParam(baseDir, 'showPublishAsIcon') if showPublishAsIcon is not None: @@ -2154,7 +2144,6 @@ if __name__ == "__main__": args.fullWidthTimelineButtonHeader, args.showPublishAsIcon, args.maxFollowers, - args.allowNewsFollowers, args.maxNewsPosts, args.maxMirroredArticles, args.maxNewswireFeedSizeKb, diff --git a/follow.py b/follow.py index f3c20967..0c9e2598 100644 --- a/follow.py +++ b/follow.py @@ -68,14 +68,9 @@ def createInitialLastSeen(baseDir: str, httpPrefix: str) -> None: def _preApprovedFollower(baseDir: str, nickname: str, domain: str, - approveHandle: str, - allowNewsFollowers: bool) -> bool: + approveHandle: str) -> bool: """Is the given handle an already manually approved follower? """ - # optionally allow the news account to be followed - if nickname == 'news' and allowNewsFollowers: - return True - handle = nickname + '@' + domain accountDir = baseDir + '/accounts/' + handle approvedFilename = accountDir + '/approved.txt' @@ -460,13 +455,12 @@ def getFollowingFeed(baseDir: str, domain: str, port: int, path: str, def _followApprovalRequired(baseDir: str, nicknameToFollow: str, domainToFollow: str, debug: bool, - followRequestHandle: str, - allowNewsFollowers: bool) -> bool: + followRequestHandle: str) -> bool: """ Returns the policy for follower approvals """ # has this handle already been manually approved? if _preApprovedFollower(baseDir, nicknameToFollow, domainToFollow, - followRequestHandle, allowNewsFollowers): + followRequestHandle): return False manuallyApproveFollows = False @@ -600,7 +594,6 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, cachedWebfingers: {}, personCache: {}, messageJson: {}, federationList: [], debug: bool, projectVersion: str, - allowNewsFollowers: bool, maxFollowers: int) -> bool: """Receives a follow request within the POST section of HTTPServer """ @@ -651,11 +644,10 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, 'nickname for the account followed') return True if isSystemAccount(nicknameToFollow): - if not (nicknameToFollow == 'news' and allowNewsFollowers): - if debug: - print('DEBUG: Cannot follow system account - ' + - nicknameToFollow) - return True + if debug: + print('DEBUG: Cannot follow system account - ' + + nicknameToFollow) + return True if maxFollowers > 0: if _getNoOfFollowers(baseDir, nicknameToFollow, domainToFollow, @@ -683,8 +675,7 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str, # what is the followers policy? approveHandle = nickname + '@' + domainFull if _followApprovalRequired(baseDir, nicknameToFollow, - domainToFollow, debug, approveHandle, - allowNewsFollowers): + domainToFollow, debug, approveHandle): print('Follow approval is required') if domain.endswith('.onion'): if _noOfFollowRequests(baseDir, @@ -877,7 +868,7 @@ def sendFollowRequest(session, baseDir: str, clientToServer: bool, federationList: [], sendThreads: [], postLog: [], cachedWebfingers: {}, personCache: {}, debug: bool, - projectVersion: str, allowNewsFollowers: bool) -> {}: + projectVersion: str) -> {}: """Gets the json object for sending a follow request """ if not domainPermitted(followDomain, federationList): @@ -910,7 +901,7 @@ def sendFollowRequest(session, baseDir: str, } if _followApprovalRequired(baseDir, nickname, domain, debug, - followHandle, allowNewsFollowers): + followHandle): # Remove any follow requests rejected for the account being followed. # It's assumed that if you are following someone then you are # ok with them following back. If this isn't the case then a rejected diff --git a/inbox.py b/inbox.py index eb04fe07..a83c1fec 100644 --- a/inbox.py +++ b/inbox.py @@ -2449,7 +2449,6 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int, maxEmoji: int, translate: {}, unitTest: bool, YTReplacementDomain: str, showPublishedDateOnly: bool, - allowNewsFollowers: bool, maxFollowers: int, allowLocalNetworkAccess: bool, peertubeInstances: []) -> None: """Processes received items and moves them to the appropriate @@ -2739,7 +2738,6 @@ def runInboxQueue(recentPostsCache: {}, maxRecentPosts: int, queueJson['post'], federationList, debug, projectVersion, - allowNewsFollowers, maxFollowers): if os.path.isfile(queueFilename): os.remove(queueFilename) diff --git a/tests.py b/tests.py index 32dd0b01..7fcdccd0 100644 --- a/tests.py +++ b/tests.py @@ -322,11 +322,12 @@ def createServerAlice(path: str, domain: str, port: int, maxNewswirePosts = 20 dormantMonths = 3 sendThreadsTimeoutMins = 30 + maxFollowers = 10 print('Server running: Alice') runDaemon(sendThreadsTimeoutMins, dormantMonths, maxNewswirePosts, allowLocalNetworkAccess, - 2048, False, True, False, False, True, 10, False, + 2048, False, True, False, False, True, maxFollowers, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, @@ -418,11 +419,12 @@ def createServerBob(path: str, domain: str, port: int, maxNewswirePosts = 20 dormantMonths = 3 sendThreadsTimeoutMins = 30 + maxFollowers = 10 print('Server running: Bob') runDaemon(sendThreadsTimeoutMins, dormantMonths, maxNewswirePosts, allowLocalNetworkAccess, - 2048, False, True, False, False, True, 10, False, + 2048, False, True, False, False, True, maxFollowers, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, @@ -464,11 +466,12 @@ def createServerEve(path: str, domain: str, port: int, federationList: [], maxNewswirePosts = 20 dormantMonths = 3 sendThreadsTimeoutMins = 30 + maxFollowers = 10 print('Server running: Eve') runDaemon(sendThreadsTimeoutMins, dormantMonths, maxNewswirePosts, allowLocalNetworkAccess, - 2048, False, True, False, False, True, 10, False, + 2048, False, True, False, False, True, maxFollowers, 0, 100, 1024, 5, False, 0, False, 1, False, False, False, 5, True, True, 'en', __version__, @@ -851,7 +854,7 @@ def testFollowBetweenServers(): clientToServer, federationList, aliceSendThreads, alicePostLog, aliceCachedWebfingers, alicePersonCache, - True, __version__, False) + True, __version__) print('sendResult: ' + str(sendResult)) for t in range(16):