diff --git a/hive/server/bridge_api/methods.py b/hive/server/bridge_api/methods.py index 8599b23b91518f62a09bb0654aa8cde57f1c4842..6276098a0c046de3f1b39ce647955acaf98cc84e 100644 --- a/hive/server/bridge_api/methods.py +++ b/hive/server/bridge_api/methods.py @@ -340,7 +340,8 @@ async def get_relationship_between_accounts(context, account1, account2, observe 'follows': False, 'ignores': False, 'is_blacklisted': False, - 'follows_blacklists': False + 'follows_blacklists': False, + 'follows_muted': False } for row in sql_result: @@ -354,6 +355,36 @@ async def get_relationship_between_accounts(context, account1, account2, observe result['is_blacklisted'] = True if row['follow_blacklists']: result['follows_blacklists'] = True + if row['follow_muted']: + result['follows_muted'] = True return result +@return_error_info +async def get_follow_list(context, observer, follow_type = 'blacklisted', starting_account = '', limit = 20): + db = context['db'] + valid_account(observer) + valid_account(starting_account, allow_empty=True) + valid_limit(limit, 100) + + valid_types = ['blacklisted', 'follow_blacklist', 'muted', 'follow_muted'] + assert follow_type in valid_types, 'invalid follow_type' + + results = [] + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) + for account in blacklists_for_user.keys(): + sources = blacklists_for_user[account] + if follow_type == 'blacklisted': + if 'my_blacklist' in sources: + results.append(account) + elif follow_type == 'follow_blacklist': + if 'my_followed_blacklists' in sources: + results.append(account) + elif follow_type == 'muted': + if 'my_muted' in sources: + results.append(account) + elif follow_type == 'follow_muted': + if 'my_followed_mutes' in sources: + results.append(account) + return results + diff --git a/hive/server/bridge_api/thread.py b/hive/server/bridge_api/thread.py index 532a250e7aba31d936bff6ad4f3b2880474bef98..d73358d029a90bf3e2d75e86b7ebcc545f7046c7 100644 --- a/hive/server/bridge_api/thread.py +++ b/hive/server/bridge_api/thread.py @@ -45,6 +45,7 @@ async def get_discussion(context, author, permlink, observer=None): INNER JOIN hive_post_data hpd ON hpd.id = hive_posts.id INNER JOIN hive_category_data hcd ON hcd.id = hp.category_id WHERE NOT hive_posts.is_deleted AND NOT hive_posts.is_muted + LIMIT 2000 """ blacklists_for_user = None diff --git a/hive/server/common/mutes.py b/hive/server/common/mutes.py index 53fc167778924a7d696f9a3e346f48f601d0b958..da0219b8eb03bdff1dfd01b8deca3ee50ef52563 100644 --- a/hive/server/common/mutes.py +++ b/hive/server/common/mutes.py @@ -19,6 +19,15 @@ WITH blacklisted_users AS ( (SELECT following FROM hive_follows WHERE follower = (SELECT id FROM hive_accounts WHERE name = :observer ) AND follow_blacklists) AND blacklisted + UNION ALL + SELECT following, 'my_muted' AS source FROM hive_follows WHERE follower = + (SELECT id FROM hive_accounts WHERE name = :observer) + AND state = 2 + UNION ALL + SELECT following, 'my_followed_mutes' AS source FROm hive_follows WHERE follower IN + (SELECT following FROM hive_follows WHERE follower = + (SELECT id FROM hive_accounts WHERE name = :observer) + AND follow_muted) AND state = 2 ) SELECT following, source FROM blacklisted_users """ @@ -96,6 +105,7 @@ class Mutes: if account_name not in blacklisted_users: blacklisted_users[account_name] = [] blacklisted_users[account_name].append(row['source']) + print('blacklist for user', blacklisted_users) return blacklisted_users @classmethod diff --git a/hive/server/condenser_api/call.py b/hive/server/condenser_api/call.py index 71f27d59fee0bcde30d7a1b54adeae21fe3f89f3..694e5cb63e7b7990f793ea29316c7cb1afa5804c 100644 --- a/hive/server/condenser_api/call.py +++ b/hive/server/condenser_api/call.py @@ -82,6 +82,7 @@ async def call(context, api, method, params): "params":["database_api","get_state",["trending"]]} ```""" # pylint: disable=too-many-return-statements, too-many-branches, no-else-return + print("api is: ", api) assert api == 'condenser_api', "`call` requires condenser_api" # Follows diff --git a/hive/server/serve.py b/hive/server/serve.py index ad75d2c0d6634e08e762cef19a314e23b79bb609..a70bb0fa8672e779d52ff8f105be01edbb3b4ac9 100644 --- a/hive/server/serve.py +++ b/hive/server/serve.py @@ -138,6 +138,7 @@ def build_methods(): bridge_api.get_profile, bridge_api.get_trending_topics, bridge_api.get_relationship_between_accounts, + bridge_api.get_follow_list, hive_api_notify.post_notifications, hive_api_notify.account_notifications, hive_api_notify.unread_notifications,