Skip to content
Snippets Groups Projects
Commit 03bbcd76 authored by Dan Notestein's avatar Dan Notestein
Browse files

Merge branch...

Merge branch 'jsalyers-new-branch-because-im-sick-of-merge-conflicts-that-shouldnt-exist' into 'develop'

[JES] Pass observer through to bridge.get_discussion

See merge request !385
parents 78d2f53d e756c082
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!385[JES] Pass observer through to bridge.get_discussion
...@@ -2,7 +2,8 @@ DROP FUNCTION IF EXISTS get_discussion ...@@ -2,7 +2,8 @@ DROP FUNCTION IF EXISTS get_discussion
; ;
CREATE OR REPLACE FUNCTION get_discussion( CREATE OR REPLACE FUNCTION get_discussion(
in _author hive_accounts.name%TYPE, 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 RETURNS TABLE
( (
...@@ -72,12 +73,13 @@ BEGIN ...@@ -72,12 +73,13 @@ BEGIN
SELECT hp.id, hp.parent_id SELECT hp.id, hp.parent_id
FROM hive_posts hp FROM hive_posts hp
WHERE hp.id = __post_id WHERE hp.id = __post_id
AND NOT hp.is_muted
UNION ALL UNION ALL
SELECT children.id, children.parent_id SELECT children.id, children.parent_id
FROM hive_posts children FROM hive_posts children
JOIN child_posts ON children.parent_id = child_posts.id 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 SELECT hp2.id
FROM hive_posts hp2 FROM hive_posts hp2
......
...@@ -26,8 +26,8 @@ async def get_discussion(context, author, permlink, observer=None): ...@@ -26,8 +26,8 @@ async def get_discussion(context, author, permlink, observer=None):
if observer: if observer:
blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context)
sql = "SELECT * FROM get_discussion(:author,:permlink)" sql = "SELECT * FROM get_discussion(:author,:permlink,:observer)"
rows = await db.query_all(sql, author=author, permlink=permlink) rows = await db.query_all(sql, author=author, permlink=permlink, observer=observer)
if not rows or len(rows) == 0: if not rows or len(rows) == 0:
return {} return {}
root_id = rows[0]['id'] root_id = rows[0]['id']
......
...@@ -234,11 +234,11 @@ async def _child_ids(db, parent_ids): ...@@ -234,11 +234,11 @@ async def _child_ids(db, parent_ids):
rows = await db.query_all(sql, ids=tuple(parent_ids)) rows = await db.query_all(sql, ids=tuple(parent_ids))
return [[row[0], row[1]] for row in rows] return [[row[0], row[1]] for row in rows]
async def _load_discussion(db, author, permlink): async def _load_discussion(db, author, permlink, observer=None):
"""Load a full discussion thread.""" """Load a full discussion thread."""
sql = "SELECT * FROM get_discussion('{}','{}')".format( author, permlink) sql = "SELECT * FROM get_discussion(:author,:permlink,:observer)"
sql_result = await db.query_all(sql) sql_result = await db.query_all(sql, author=author, permlink=permlink, observer=observer)
muted_accounts = Mutes.all() muted_accounts = Mutes.all()
posts = [] posts = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment