hide_comments
now returns lists for both hidden
and visible
comments
This commit is contained in:
parent
149d343201
commit
006494b1fa
2 changed files with 25 additions and 13 deletions
|
@ -5154,10 +5154,11 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
--comment_ids=<comment_ids> : (str, list) one or more comment_id to hide.
|
||||
--wallet_id=<wallet_id> : (str) restrict operation to specific wallet
|
||||
|
||||
Returns:
|
||||
(dict) keyed by comment_id, containing success info
|
||||
'<comment_id>': {
|
||||
"hidden": (bool) flag indicating if comment_id was hidden
|
||||
Returns: lists containing the ids comments that are hidden and visible.
|
||||
|
||||
{
|
||||
"hidden": (list) IDs of hidden comments.
|
||||
"visible": (list) IDs of visible comments.
|
||||
}
|
||||
"""
|
||||
wallet = self.wallet_manager.get_wallet_or_default(wallet_id)
|
||||
|
@ -5165,9 +5166,8 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
if isinstance(comment_ids, str):
|
||||
comment_ids = [comment_ids]
|
||||
|
||||
comments = await comment_client.jsonrpc_post(
|
||||
self.conf.comment_server, 'get_comments_by_id', comment_ids=comment_ids
|
||||
)
|
||||
comments = await comment_client.jsonrpc_post(self.conf.comment_server, 'get_comments_by_id', comment_ids=comment_ids)
|
||||
comments = comments['items']
|
||||
claim_ids = {comment['claim_id'] for comment in comments}
|
||||
claims = {cid: await self.ledger.get_claim_by_claim_id(wallet.accounts, claim_id=cid) for cid in claim_ids}
|
||||
pieces = []
|
||||
|
|
|
@ -106,11 +106,16 @@ class MockedCommentServer:
|
|||
return False
|
||||
|
||||
def hide_comments(self, pieces: list):
|
||||
comments_hidden = []
|
||||
hidden = []
|
||||
for p in pieces:
|
||||
if self.hide_comment(**p):
|
||||
comments_hidden.append(p['comment_id'])
|
||||
return {'hidden': comments_hidden}
|
||||
hidden.append(p['comment_id'])
|
||||
|
||||
comment_ids = {c['comment_id'] for c in pieces}
|
||||
return {
|
||||
'hidden': hidden,
|
||||
'visible': list(comment_ids - set(hidden))
|
||||
}
|
||||
|
||||
def get_claim_comments(self, claim_id, page=1, page_size=50,**kwargs):
|
||||
comments = list(filter(lambda c: c['claim_id'] == claim_id, self.comments))
|
||||
|
@ -138,12 +143,19 @@ class MockedCommentServer:
|
|||
def get_comment_channel_by_id(self, comment_id: int, **kwargs):
|
||||
comment = self.comments[self.get_comment_id(comment_id)]
|
||||
return {
|
||||
'channel_id': comment.get('channel_id'),
|
||||
'channel_name': comment.get('channel_name')
|
||||
'channel_id': comment['channel_id'],
|
||||
'channel_name': comment['channel_name'],
|
||||
}
|
||||
|
||||
def get_comments_by_id(self, comment_ids: list):
|
||||
return [self.comments[self.get_comment_id(cid)] for cid in comment_ids]
|
||||
comments = [self.comments[self.get_comment_id(cid)] for cid in comment_ids]
|
||||
return {
|
||||
'page': 1,
|
||||
'page_size': len(comment_ids),
|
||||
'total_pages': 1,
|
||||
'items': comments,
|
||||
'has_hidden_comments': bool({c for c in comments if c['is_hidden']})
|
||||
}
|
||||
|
||||
methods = {
|
||||
'get_claim_comments': get_claim_comments,
|
||||
|
|
Loading…
Reference in a new issue