From 40430b2456e3af4ea31cc19363f66ea31d39c217 Mon Sep 17 00:00:00 2001 From: jsalyers <jsalyers@syncad.com> Date: Mon, 16 Nov 2020 19:36:06 -0500 Subject: [PATCH] [JES] Pass observer through to bridge.get_discussion --- hive/db/sql_scripts/bridge_get_discussion.sql | 8 +++++--- hive/server/bridge_api/thread.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/hive/db/sql_scripts/bridge_get_discussion.sql b/hive/db/sql_scripts/bridge_get_discussion.sql index c033afce1..1870082d7 100644 --- a/hive/db/sql_scripts/bridge_get_discussion.sql +++ b/hive/db/sql_scripts/bridge_get_discussion.sql @@ -2,7 +2,8 @@ DROP FUNCTION IF EXISTS get_discussion ; CREATE OR REPLACE FUNCTION get_discussion( in _author hive_accounts.name%TYPE, - in _permlink hive_permlink_data.permlink%TYPE + in _permlink hive_permlink_data.permlink%TYPE, + in _observer VARCHAR ) RETURNS TABLE ( @@ -72,12 +73,13 @@ BEGIN SELECT hp.id, hp.parent_id FROM hive_posts hp WHERE hp.id = __post_id - AND NOT hp.is_muted UNION ALL SELECT children.id, children.parent_id FROM hive_posts children JOIN child_posts ON children.parent_id = child_posts.id - WHERE children.counter_deleted = 0 AND NOT children.is_muted + JOIN hive_accounts ON children.author_id = hive_accounts.id + WHERE children.counter_deleted = 0 AND + (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hive_accounts.name) ELSE True END) ) SELECT hp2.id FROM hive_posts hp2 diff --git a/hive/server/bridge_api/thread.py b/hive/server/bridge_api/thread.py index 213e561bf..b812a41f0 100644 --- a/hive/server/bridge_api/thread.py +++ b/hive/server/bridge_api/thread.py @@ -26,8 +26,8 @@ async def get_discussion(context, author, permlink, observer=None): if observer: blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) - sql = "SELECT * FROM get_discussion(:author,:permlink)" - rows = await db.query_all(sql, author=author, permlink=permlink) + sql = "SELECT * FROM get_discussion(:author,:permlink,:observer)" + rows = await db.query_all(sql, author=author, permlink=permlink, observer=observer) if not rows or len(rows) == 0: return {} root_id = rows[0]['id'] -- GitLab