reposts can have title, description and tags

This commit is contained in:
Lex Berezhny 2022-06-08 10:35:22 -04:00
parent c04fbb2908
commit fe61b90610
2 changed files with 30 additions and 8 deletions

View file

@ -3301,15 +3301,17 @@ class Daemon(metaclass=JSONRPCServerType):
) )
@requires(WALLET_COMPONENT, FILE_MANAGER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT) @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, 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, channel_name=None, channel_account_id=None, account_id=None, wallet_id=None,
claim_address=None, funding_account_ids=None, preview=False, blocking=False): claim_address=None, funding_account_ids=None, preview=False, blocking=False, **kwargs):
""" """
Creates a claim that references an existing stream by its claim id. Creates a claim that references an existing stream by its claim id.
Usage: Usage:
stream_repost (<name> | --name=<name>) (<bid> | --bid=<bid>) (<claim_id> | --claim_id=<claim_id>) stream_repost (<name> | --name=<name>) (<bid> | --bid=<bid>) (<claim_id> | --claim_id=<claim_id>)
[--allow_duplicate_name=<allow_duplicate_name>] [--allow_duplicate_name=<allow_duplicate_name>]
[--title=<title>] [--description=<description>] [--tags=<tags>...]
[--channel_id=<channel_id> | --channel_name=<channel_name>] [--channel_id=<channel_id> | --channel_name=<channel_name>]
[--channel_account_id=<channel_account_id>...] [--channel_account_id=<channel_account_id>...]
[--account_id=<account_id>] [--wallet_id=<wallet_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 --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 --allow_duplicate_name=<allow_duplicate_name> : (bool) create new claim even if one already exists with
given name. default: false. 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_id=<channel_id> : (str) claim id of the publisher channel
--channel_name=<channel_name> : (str) name 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 --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.') raise Exception('Invalid claim id. It is expected to be a 40 characters long hexadecimal string.')
claim = Claim() claim = Claim()
claim.repost.update(**kwargs)
claim.repost.reference.claim_id = claim_id claim.repost.reference.claim_id = claim_id
tx = await Transaction.claim_create( tx = await Transaction.claim_create(
name, claim, amount, claim_address, funding_accounts, funding_accounts[0], channel 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: if old_txo.claim.is_stream:
claim.stream.update(file_path=file_path, **kwargs) claim.stream.update(file_path=file_path, **kwargs)
elif old_txo.claim.is_repost:
claim.repost.update(**kwargs)
if clear_channel: if clear_channel:
claim.clear_signature() claim.clear_signature()

View file

@ -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(reposted_claim_id=claim_id), 0)
self.assertItemCount(await self.daemon.jsonrpc_txo_list(type='repost'), 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) repost_id = self.get_claim_id(tx)
# test inflating reposted channels works # test inflating reposted channels works
repost_url = f'newstuff-again:{repost_id}' repost_url = f'newstuff-again:{repost_id}'
self.ledger._tx_cache.clear() self.ledger._tx_cache.clear()
self.assertEqual( repost_resolve = await self.out(self.daemon.jsonrpc_resolve(repost_url))
goodies_claim_id, repost = repost_resolve[repost_url]
(await self.out(self.daemon.jsonrpc_resolve(repost_url)) self.assertEqual(goodies_claim_id, repost['reposted_claim']['signing_channel']['claim_id'])
)[repost_url]['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.assertItemCount(await self.daemon.jsonrpc_claim_list(claim_type='repost'), 1)
self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 1) self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 1)