From 47601da0be4a01c977f51cf1c43e37a71e7e3e66 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 17 Oct 2021 18:45:49 +0100 Subject: [PATCH] Remove unfollow before new follow --- follow.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/follow.py b/follow.py index ba192fbd0..522bb92cb 100644 --- a/follow.py +++ b/follow.py @@ -1009,6 +1009,19 @@ def sendFollowRequest(session, baseDir: str, singleUserNickname = 'dev' followHandle = singleUserNickname + '@' + requestDomain + # remove follow handle from unfollowed.txt + unfollowedFilename = acctDir(baseDir, nickname, domain) + '/unfollowed.txt' + if os.path.isfile(unfollowedFilename): + if followHandle in open(unfollowedFilename).read(): + unfollowedFile = None + with open(unfollowedFilename, 'r') as fp: + unfollowedFile = fp.read() + unfollowedFile = \ + unfollowedFile.replace(followHandle + '\n', '') + if unfollowedFile: + with open(unfollowedFilename, 'w+') as fp: + fp.write(unfollowedFile) + newFollowJson = { '@context': 'https://www.w3.org/ns/activitystreams', 'id': followActor + '/statuses/' + str(statusNumber),