Skip to content
Snippets Groups Projects
Commit 7b8498ca authored by roadscape's avatar roadscape
Browse files

add post_notifications endpoint

parent cba79c7b
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ import logging ...@@ -3,7 +3,7 @@ import logging
from hive.server.common.helpers import return_error_info, json_date from hive.server.common.helpers import return_error_info, json_date
from hive.indexer.notify import NotifyType from hive.indexer.notify import NotifyType
from hive.server.hive_api.common import get_account_id, valid_limit from hive.server.hive_api.common import get_account_id, valid_limit, get_post_id
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -72,6 +72,21 @@ async def account_notifications(context, account, min_score=25, last_id=None, li ...@@ -72,6 +72,21 @@ async def account_notifications(context, account, min_score=25, last_id=None, li
last_id=last_id, limit=limit) last_id=last_id, limit=limit)
return [_render(row) for row in rows] return [_render(row) for row in rows]
@return_error_info
async def post_notifications(context, author, permlink, min_score=25, last_id=None, limit=100):
"""Load notifications for a specific post."""
# pylint: disable=too-many-arguments
db = context['db']
limit = valid_limit(limit, 100)
post_id = await get_post_id(db, author, permlink)
seek = ' AND hn.id < :last_id' if last_id else ''
sql = _notifs_sql("post_id = :post_id" + seek)
rows = await db.query_all(sql, min_score=min_score, post_id=post_id,
last_id=last_id, limit=limit)
return [_render(row) for row in rows]
def _notifs_sql(where): def _notifs_sql(where):
sql = """SELECT hn.id, hn.type_id, hn.score, hn.created_at, sql = """SELECT hn.id, hn.type_id, hn.score, hn.created_at,
src.name src, dst.name dst, src.name src, dst.name dst,
......
...@@ -122,6 +122,7 @@ def build_methods(): ...@@ -122,6 +122,7 @@ def build_methods():
bridge_api.get_ranked_posts, bridge_api.get_ranked_posts,
bridge_api.get_profile, bridge_api.get_profile,
bridge_api.get_trending_topics, bridge_api.get_trending_topics,
hive_api_notify.post_notifications,
hive_api_notify.account_notifications, hive_api_notify.account_notifications,
hive_api_notify.unread_notifications, hive_api_notify.unread_notifications,
hive_api_stats.get_payout_stats, hive_api_stats.get_payout_stats,
......
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