Skip to content
Snippets Groups Projects
Commit 7b0cab06 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'jsalyers-blacklist-v2' into 'develop'

Jsalyers blacklist v2

See merge request !421
parents 9901ec3b b4cd8e01
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!421Jsalyers blacklist v2
......@@ -15,15 +15,14 @@ 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'] = []
if blacklisted_for_user and row['author'] in blacklisted_for_user:
blacklists = blacklisted_for_user[row['author']]
post['blacklists'].extend(blacklists[0])
for mute_list in blacklists[1]:
post['blacklists'].append(mute_list + ' (mute list)')
if 'blacklists' in row and row['blacklists']:
split_lists = row['blacklists'].split(',')
for blacklist_source in split_lists:
post['blacklists'].append(blacklist_source)
reputation = post['author_reputation']
if reputation < 1:
post['blacklists'].append('reputation-0')
......
......@@ -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
......
Subproject commit 527f27b14bdf10c8a543b015dc3cad0afb0ada6c
Subproject commit 7e65efd650e0d8bc41e194638121ce4b195ae29c
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment