forked from LBRYCommunity/lbry-sdk
reposts can have title, description and tags
This commit is contained in:
parent
c04fbb2908
commit
fe61b90610
2 changed files with 30 additions and 8 deletions
|
@ -3301,15 +3301,17 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
)
|
||||
|
||||
@requires(WALLET_COMPONENT, FILE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT)
|
||||
async def jsonrpc_stream_repost(self, name, bid, claim_id, allow_duplicate_name=False, channel_id=None,
|
||||
channel_name=None, channel_account_id=None, account_id=None, wallet_id=None,
|
||||
claim_address=None, funding_account_ids=None, preview=False, blocking=False):
|
||||
async def jsonrpc_stream_repost(
|
||||
self, name, bid, claim_id, allow_duplicate_name=False, channel_id=None,
|
||||
channel_name=None, channel_account_id=None, account_id=None, wallet_id=None,
|
||||
claim_address=None, funding_account_ids=None, preview=False, blocking=False, **kwargs):
|
||||
"""
|
||||
Creates a claim that references an existing stream by its claim id.
|
||||
|
||||
Usage:
|
||||
stream_repost (<name> | --name=<name>) (<bid> | --bid=<bid>) (<claim_id> | --claim_id=<claim_id>)
|
||||
[--allow_duplicate_name=<allow_duplicate_name>]
|
||||
[--title=<title>] [--description=<description>] [--tags=<tags>...]
|
||||
[--channel_id=<channel_id> | --channel_name=<channel_name>]
|
||||
[--channel_account_id=<channel_account_id>...]
|
||||
[--account_id=<account_id>] [--wallet_id=<wallet_id>]
|
||||
|
@ -3322,6 +3324,9 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
--claim_id=<claim_id> : (str) id of the claim being reposted
|
||||
--allow_duplicate_name=<allow_duplicate_name> : (bool) create new claim even if one already exists with
|
||||
given name. default: false.
|
||||
--title=<title> : (str) title of the repost
|
||||
--description=<description> : (str) description of the repost
|
||||
--tags=<tags> : (list) add repost tags
|
||||
--channel_id=<channel_id> : (str) claim id of the publisher channel
|
||||
--channel_name=<channel_name> : (str) name of the publisher channel
|
||||
--channel_account_id=<channel_account_id>: (str) one or more account ids for accounts to look in
|
||||
|
@ -3356,6 +3361,7 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
raise Exception('Invalid claim id. It is expected to be a 40 characters long hexadecimal string.')
|
||||
|
||||
claim = Claim()
|
||||
claim.repost.update(**kwargs)
|
||||
claim.repost.reference.claim_id = claim_id
|
||||
tx = await Transaction.claim_create(
|
||||
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel
|
||||
|
@ -3736,6 +3742,8 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
|
||||
if old_txo.claim.is_stream:
|
||||
claim.stream.update(file_path=file_path, **kwargs)
|
||||
elif old_txo.claim.is_repost:
|
||||
claim.repost.update(**kwargs)
|
||||
|
||||
if clear_channel:
|
||||
claim.clear_signature()
|
||||
|
|
|
@ -1455,17 +1455,31 @@ class StreamCommands(ClaimTestCase):
|
|||
self.assertItemCount(await self.daemon.jsonrpc_txo_list(reposted_claim_id=claim_id), 0)
|
||||
self.assertItemCount(await self.daemon.jsonrpc_txo_list(type='repost'), 0)
|
||||
|
||||
tx = await self.stream_repost(claim_id, 'newstuff-again', '1.1', channel_name='@spam')
|
||||
tx = await self.stream_repost(
|
||||
claim_id, 'newstuff-again', '1.1', channel_name='@spam',
|
||||
title="repost title", description="repost desc", tags=["tag1", "tag2"]
|
||||
)
|
||||
repost_id = self.get_claim_id(tx)
|
||||
|
||||
# test inflating reposted channels works
|
||||
repost_url = f'newstuff-again:{repost_id}'
|
||||
self.ledger._tx_cache.clear()
|
||||
self.assertEqual(
|
||||
goodies_claim_id,
|
||||
(await self.out(self.daemon.jsonrpc_resolve(repost_url))
|
||||
)[repost_url]['reposted_claim']['signing_channel']['claim_id']
|
||||
repost_resolve = await self.out(self.daemon.jsonrpc_resolve(repost_url))
|
||||
repost = repost_resolve[repost_url]
|
||||
self.assertEqual(goodies_claim_id, repost['reposted_claim']['signing_channel']['claim_id'])
|
||||
self.assertEqual("repost title", repost["value"]["title"])
|
||||
self.assertEqual("repost desc", repost["value"]["description"])
|
||||
self.assertEqual(["tag1", "tag2"], repost["value"]["tags"])
|
||||
|
||||
await self.stream_update(
|
||||
repost_id, title="title 2", description="desc 2", tags=["tag3"]
|
||||
)
|
||||
repost_resolve = await self.out(self.daemon.jsonrpc_resolve(repost_url))
|
||||
repost = repost_resolve[repost_url]
|
||||
self.assertEqual(goodies_claim_id, repost['reposted_claim']['signing_channel']['claim_id'])
|
||||
self.assertEqual("title 2", repost["value"]["title"])
|
||||
self.assertEqual("desc 2", repost["value"]["description"])
|
||||
self.assertEqual(["tag1", "tag2", "tag3"], repost["value"]["tags"])
|
||||
|
||||
self.assertItemCount(await self.daemon.jsonrpc_claim_list(claim_type='repost'), 1)
|
||||
self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 1)
|
||||
|
|
Loading…
Reference in a new issue