From 65c783e6de6b7e067adf9c9f3a575e6bfd88a3a3 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@libreserver.org>
Date: Tue, 29 Nov 2022 21:56:36 +0000
Subject: [PATCH] Check that not already following the moved account

---
 relationships.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/relationships.py b/relationships.py
index 639b17c7d..3e86b26c2 100644
--- a/relationships.py
+++ b/relationships.py
@@ -37,14 +37,6 @@ def get_moved_accounts(base_dir: str, nickname: str, domain: str,
               moved_accounts_filename)
     refollow_list = refollow_str.split('\n')
     refollow_dict = {}
-    ctr = 0
-    for line in refollow_list:
-        if ' ' not in line:
-            continue
-        prev_handle = line.split(' ')[0]
-        new_handle = line.split(' ')[1]
-        refollow_dict[prev_handle] = new_handle
-        ctr = ctr + 1
 
     follow_filename = \
         acct_dir(base_dir, nickname, domain) + '/' + filename
@@ -58,10 +50,20 @@ def get_moved_accounts(base_dir: str, nickname: str, domain: str,
               follow_filename)
     follow_list = follow_str.split('\n')
 
+    ctr = 0
+    for line in refollow_list:
+        if ' ' not in line:
+            continue
+        prev_handle = line.split(' ')[0]
+        new_handle = line.split(' ')[1]
+        refollow_dict[prev_handle] = new_handle
+        ctr = ctr + 1
+
     result = {}
     for handle in follow_list:
         if refollow_dict.get(handle):
-            result[handle] = refollow_dict[handle]
+            if refollow_dict[handle] not in follow_list:
+                result[handle] = refollow_dict[handle]
     return result