diff --git a/hive/db/sql_scripts/bridge_get_discussion.sql b/hive/db/sql_scripts/bridge_get_discussion.sql index c033afce13f04dc1628b37169c107acc5023625d..1870082d7d45bee92711fca7e694fd7e91aebc77 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 213e561bfbca82aef0baa054e945ab446692e34b..b812a41f08ccad14b0c6f0ff569f8c9f5e75ffaf 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']