From 5467b448c79b0d46561d6dfe1b87202e895be804 Mon Sep 17 00:00:00 2001
From: Dariusz Kedzierski <dkedzierski@syncad.com>
Date: Fri, 6 Nov 2020 23:21:03 +0100
Subject: [PATCH] Follower and following entries must be strings. Same
 behaviour as in old hivemind

---
 hive/indexer/follow.py | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/hive/indexer/follow.py b/hive/indexer/follow.py
index 3cfa5f5b5..9c77b26d8 100644
--- a/hive/indexer/follow.py
+++ b/hive/indexer/follow.py
@@ -104,18 +104,15 @@ class Follow(DbAdapterHolder):
         op['following'] = op['following'] if isinstance(op['following'], list) else [op['following']]
         
         # additional layer of protection against putting complex data types as user names
-        as_str = []
+        # we expecting follower and following entries to be strings
+        # in older hivemind this check was done in Accounts.exists
+        # now following can be list of names so we need to check if all entries are strings
         for following in op['following']:
-            if isinstance(following, list) or isinstance(following, dict):
-                as_str.append(dumps(following))
-            else:
-                as_str.append(str(following))
-        op['following'] = as_str
+            if not isinstance(following, str):
+                return None
 
-        if isinstance(op['follower'], list) or isinstance(op['follower'], dict):
-            op['follower'] = dumps(op['follower'])
-        else:
-            op['follower'] = str(op['follower'])
+        if not isinstance(op['follower'], str):
+            return None
 
         # follower/following is empty
         if not op['follower'] or not op['following']:
-- 
GitLab