Skip to content

Commit

Permalink
Merge fe61b90 into c04fbb2
Browse files Browse the repository at this point in the history
  • Loading branch information
eukreign committed Jun 8, 2022
2 parents c04fbb2 + fe61b90 commit f4744b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
14 changes: 11 additions & 3 deletions lbry/extras/daemon/daemon.py
Expand Up @@ -3301,15 +3301,17 @@ async def jsonrpc_publish(self, name, **kwargs):
)

@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>]
Expand All @@ -3322,6 +3324,9 @@ async def jsonrpc_stream_repost(self, name, bid, claim_id, allow_duplicate_name=
--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
Expand Down Expand Up @@ -3356,6 +3361,7 @@ async def jsonrpc_stream_repost(self, name, bid, claim_id, allow_duplicate_name=
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
Expand Down Expand Up @@ -3736,6 +3742,8 @@ async def jsonrpc_stream_update(

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()
Expand Down
24 changes: 19 additions & 5 deletions tests/integration/claims/test_claim_commands.py
Expand Up @@ -1455,17 +1455,31 @@ async def test_repost(self):
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)
Expand Down

0 comments on commit f4744b1

Please sign in to comment.