Makes claim_id and parent_id mutually exclusive for comment create

This commit is contained in:
Oleg Silkin 2020-01-04 01:05:48 -05:00 committed by Lex Berezhny
parent 78606ed4b8
commit 832020fa81
3 changed files with 10 additions and 6 deletions

View file

@ -4503,15 +4503,14 @@ class Daemon(metaclass=JSONRPCServerType):
return result
@requires(WALLET_COMPONENT)
async def jsonrpc_comment_create(self, claim_id, comment, parent_id=None, channel_account_id=None,
async def jsonrpc_comment_create(self, comment, claim_id=None, parent_id=None, channel_account_id=None,
channel_name=None, channel_id=None, wallet_id=None):
"""
Create and associate a comment with a claim using your channel identity.
Usage:
comment_create (<comment> | --comment=<comment>)
(<claim_id> | --claim_id=<claim_id>)
[--parent_id=<parent_id>]
(<claim_id> | --claim_id=<claim_id> | --parent_id=<parent_id>)
[--channel_id=<channel_id>] [--channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...] [--wallet_id=<wallet_id>]

View file

@ -336,8 +336,7 @@ class Examples(CommandTestCase):
'You can r',
'comment', 'create',
'--comment="I have photographic evidence confirming Sasquatch exists"',
f'--channel_name=@channel', f'--claim_id={stream_id}',
f'--parent_id={comment["comment_id"]}'
f'--channel_name=@channel', f'--parent_id={comment["comment_id"]}'
)
await r(

View file

@ -47,15 +47,21 @@ class MockedCommentServer:
schema.update(**kwargs)
return schema
def create_comment(self, channel_name=None, channel_id=None, **kwargs):
def create_comment(self, claim_id=None, parent_id=None, channel_name=None, channel_id=None, **kwargs):
comment_id = self.comment_id
channel_url = 'lbry://' + channel_name + '#' + channel_id if channel_id else None
if parent_id:
claim_id = self.comments[self.get_comment_id(parent_id)]['claim_id']
comment = self._create_comment(
comment_id=str(comment_id),
channel_name=channel_name,
channel_id=channel_id,
channel_url=channel_url,
timestamp=str(int(time.time())),
claim_id=claim_id,
parent_id=parent_id,
**kwargs
)
self.comments.append(comment)