From 6662c9d04c6b18ad708d08eae38e1a6a6a8cae8c Mon Sep 17 00:00:00 2001 From: jsalyers <jsalyers@syncad.com> Date: Fri, 4 Dec 2020 11:49:41 -0500 Subject: [PATCH] [JES] Remove the old style of fetching blacklists on posts as it now comes in from the SQL results --- hive/server/bridge_api/methods.py | 19 +++---------------- hive/server/bridge_api/objects.py | 2 +- hive/server/bridge_api/thread.py | 8 ++------ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/hive/server/bridge_api/methods.py b/hive/server/bridge_api/methods.py index a2bb35e6c..9735dd01f 100644 --- a/hive/server/bridge_api/methods.py +++ b/hive/server/bridge_api/methods.py @@ -58,16 +58,12 @@ async def get_post(context, author, permlink, observer=None): valid_account(observer, allow_empty=True) valid_permlink(permlink) - blacklisted_for_user = None - if observer: - blacklisted_for_user = await Mutes.get_blacklisted_for_observer(observer, context) - sql = "SELECT * FROM bridge_get_post( (:author)::VARCHAR, (:permlink)::VARCHAR )" result = await db.query_all(sql, author=author, permlink=permlink) post = _bridge_post_object(result[0]) post['active_votes'] = await find_votes_impl(db, author, permlink, VotesPresentation.BridgeApi) - post = append_statistics_to_post(post, result[0], False, blacklisted_for_user) + post = append_statistics_to_post(post, result[0], False) return post @return_error_info @@ -233,14 +229,11 @@ async def get_ranked_posts(context, sort:str, start_author:str='', start_permlin db = context['db'] async def process_query_results( sql_result ): - blacklisted_for_user = None - if observer: - blacklisted_for_user = await Mutes.get_blacklisted_for_observer(observer, context) posts = [] for row in sql_result: post = _bridge_post_object(row) post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.BridgeApi) - post = append_statistics_to_post(post, row, row['is_pinned'], blacklisted_for_user) + post = append_statistics_to_post(post, row, row['is_pinned']) posts.append(post) return posts @@ -298,12 +291,6 @@ async def get_account_posts(context, sort:str, account:str, start_author:str='', sql_result = await db.query_all(sql, account=account, author=start_author, permlink=start_permlink, limit=limit ) posts = [] - blacklisted_for_user = None - if observer and account_posts: - # it looks like the opposite would make more sense, that is, to handle observer for 'blog', 'feed' and 'replies', - # since that's when posts can come from various authors, some blacklisted and some not, but original version - # ignored it (only) in those cases - blacklisted_for_user = await Mutes.get_blacklisted_for_observer(observer, context) for row in sql_result: post = _bridge_post_object(row) @@ -319,7 +306,7 @@ async def get_account_posts(context, sort:str, account:str, start_author:str='', reblogged_by_list.sort() post['reblogged_by'] = reblogged_by_list - post = append_statistics_to_post(post, row, False if account_posts else row['is_pinned'], blacklisted_for_user) + post = append_statistics_to_post(post, row, False if account_posts else row['is_pinned']) posts.append(post) return posts diff --git a/hive/server/bridge_api/objects.py b/hive/server/bridge_api/objects.py index eb8dbc6e0..fe52517f8 100644 --- a/hive/server/bridge_api/objects.py +++ b/hive/server/bridge_api/objects.py @@ -15,7 +15,7 @@ log = logging.getLogger(__name__) # pylint: disable=too-many-lines -def append_statistics_to_post(post, row, is_pinned, blacklisted_for_user={}): +def append_statistics_to_post(post, row, is_pinned): """ apply information such as blacklists and community names/roles to a given post """ post['blacklists'] = [] diff --git a/hive/server/bridge_api/thread.py b/hive/server/bridge_api/thread.py index bafe0c768..e184dc43c 100644 --- a/hive/server/bridge_api/thread.py +++ b/hive/server/bridge_api/thread.py @@ -21,10 +21,6 @@ async def get_discussion(context, author:str, permlink:str, observer:str=''): permlink = valid_permlink(permlink) observer = valid_account(observer, allow_empty=True) - blacklisted_for_user = None - if observer: - blacklisted_for_user = await Mutes.get_blacklisted_for_observer(observer, context) - sql = "SELECT * FROM bridge_get_discussion(:author,:permlink,:observer)" rows = await db.query_all(sql, author=author, permlink=permlink, observer=observer) if not rows or len(rows) == 0: @@ -33,7 +29,7 @@ async def get_discussion(context, author:str, permlink:str, observer:str=''): all_posts = {} root_post = _bridge_post_object(rows[0]) root_post['active_votes'] = await find_votes_impl(db, rows[0]['author'], rows[0]['permlink'], VotesPresentation.BridgeApi) - root_post = append_statistics_to_post(root_post, rows[0], False, blacklisted_for_user) + root_post = append_statistics_to_post(root_post, rows[0], False) root_post['replies'] = [] all_posts[root_id] = root_post @@ -46,7 +42,7 @@ async def get_discussion(context, author:str, permlink:str, observer:str=''): parent_to_children_id_map[parent_id].append(rows[index]['id']) post = _bridge_post_object(rows[index]) post['active_votes'] = await find_votes_impl(db, rows[index]['author'], rows[index]['permlink'], VotesPresentation.BridgeApi) - post = append_statistics_to_post(post, rows[index], False, blacklisted_for_user) + post = append_statistics_to_post(post, rows[index], False) post['replies'] = [] all_posts[post['post_id']] = post -- GitLab