Merge pull request #3537 from lbryio/repost_update
This commit is contained in:
commit
c96d1d9c32
2 changed files with 30 additions and 18 deletions
|
@ -37,7 +37,8 @@ from lbry.dht.peer import make_kademlia_peer
|
||||||
from lbry.error import (
|
from lbry.error import (
|
||||||
DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError,
|
DownloadSDTimeoutError, ComponentsNotStartedError, ComponentStartConditionNotMetError,
|
||||||
CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError,
|
CommandDoesNotExistError, BaseError, WalletNotFoundError, WalletAlreadyLoadedError, WalletAlreadyExistsError,
|
||||||
ConflictingInputValueError, AlreadyPurchasedError, PrivateKeyNotFoundError, InputStringIsBlankError
|
ConflictingInputValueError, AlreadyPurchasedError, PrivateKeyNotFoundError, InputStringIsBlankError,
|
||||||
|
InputValueError
|
||||||
)
|
)
|
||||||
from lbry.extras import system_info
|
from lbry.extras import system_info
|
||||||
from lbry.extras.daemon import analytics
|
from lbry.extras.daemon import analytics
|
||||||
|
@ -3614,15 +3615,17 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
)
|
)
|
||||||
if len(existing_claims) != 1:
|
if len(existing_claims) != 1:
|
||||||
account_ids = ', '.join(f"'{account.id}'" for account in accounts)
|
account_ids = ', '.join(f"'{account.id}'" for account in accounts)
|
||||||
# TODO: use error from lbry.error
|
raise InputValueError(
|
||||||
raise Exception(
|
|
||||||
f"Can't find the stream '{claim_id}' in account(s) {account_ids}."
|
f"Can't find the stream '{claim_id}' in account(s) {account_ids}."
|
||||||
)
|
)
|
||||||
|
|
||||||
old_txo = existing_claims[0]
|
old_txo = existing_claims[0]
|
||||||
if not old_txo.claim.is_stream:
|
if not old_txo.claim.is_stream and not old_txo.claim.is_repost:
|
||||||
# TODO: use error from lbry.error
|
# in principle it should work with any type of claim, but its safer to
|
||||||
raise Exception(
|
# limit it to ones we know won't be broken. in the future we can expand
|
||||||
f"A claim with id '{claim_id}' was found but it is not a stream claim."
|
# this if we have a test case for e.g. channel or support claims
|
||||||
|
raise InputValueError(
|
||||||
|
f"A claim with id '{claim_id}' was found but it is not a stream or repost claim."
|
||||||
)
|
)
|
||||||
|
|
||||||
if bid is not None:
|
if bid is not None:
|
||||||
|
@ -3653,28 +3656,32 @@ class Daemon(metaclass=JSONRPCServerType):
|
||||||
|
|
||||||
if replace:
|
if replace:
|
||||||
claim = Claim()
|
claim = Claim()
|
||||||
if old_txo.claim.stream.has_source:
|
if old_txo.claim.is_stream:
|
||||||
claim.stream.message.source.CopyFrom(
|
if old_txo.claim.stream.has_source:
|
||||||
old_txo.claim.stream.message.source
|
claim.stream.message.source.CopyFrom(
|
||||||
)
|
old_txo.claim.stream.message.source
|
||||||
stream_type = old_txo.claim.stream.stream_type
|
)
|
||||||
if stream_type:
|
stream_type = old_txo.claim.stream.stream_type
|
||||||
old_stream_type = getattr(old_txo.claim.stream.message, stream_type)
|
if stream_type:
|
||||||
new_stream_type = getattr(claim.stream.message, stream_type)
|
old_stream_type = getattr(old_txo.claim.stream.message, stream_type)
|
||||||
new_stream_type.CopyFrom(old_stream_type)
|
new_stream_type = getattr(claim.stream.message, stream_type)
|
||||||
claim.stream.update(file_path=file_path, **kwargs)
|
new_stream_type.CopyFrom(old_stream_type)
|
||||||
else:
|
else:
|
||||||
claim = Claim.from_bytes(old_txo.claim.to_bytes())
|
claim = Claim.from_bytes(old_txo.claim.to_bytes())
|
||||||
|
|
||||||
|
if old_txo.claim.is_stream:
|
||||||
claim.stream.update(file_path=file_path, **kwargs)
|
claim.stream.update(file_path=file_path, **kwargs)
|
||||||
|
|
||||||
if clear_channel:
|
if clear_channel:
|
||||||
claim.clear_signature()
|
claim.clear_signature()
|
||||||
tx = await Transaction.claim_update(
|
tx = await Transaction.claim_update(
|
||||||
old_txo, claim, amount, claim_address, funding_accounts, funding_accounts[0],
|
old_txo, claim, amount, claim_address, funding_accounts, funding_accounts[0],
|
||||||
channel if not clear_channel else None
|
channel if not clear_channel else None
|
||||||
)
|
)
|
||||||
|
|
||||||
new_txo = tx.outputs[0]
|
new_txo = tx.outputs[0]
|
||||||
stream_hash = None
|
stream_hash = None
|
||||||
if not preview:
|
if not preview and old_txo.claim.is_stream:
|
||||||
old_stream = self.file_manager.get_filtered(sd_hash=old_txo.claim.stream.source.sd_hash)
|
old_stream = self.file_manager.get_filtered(sd_hash=old_txo.claim.stream.source.sd_hash)
|
||||||
old_stream = old_stream[0] if old_stream else None
|
old_stream = old_stream[0] if old_stream else None
|
||||||
if file_path is not None:
|
if file_path is not None:
|
||||||
|
|
|
@ -1499,6 +1499,11 @@ class StreamCommands(ClaimTestCase):
|
||||||
self.assertEqual(resolved['@reposting-goodies/repost-on-channel'], search)
|
self.assertEqual(resolved['@reposting-goodies/repost-on-channel'], search)
|
||||||
self.assertEqual(resolved['newstuff-again']['reposted_claim']['name'], 'newstuff')
|
self.assertEqual(resolved['newstuff-again']['reposted_claim']['name'], 'newstuff')
|
||||||
|
|
||||||
|
await self.stream_update(repost_id, bid='0.42')
|
||||||
|
searched_repost = (await self.claim_search(claim_id=repost_id))[0]
|
||||||
|
self.assertEqual(searched_repost['amount'], '0.42')
|
||||||
|
self.assertEqual(searched_repost['signing_channel']['claim_id'], spam_claim_id)
|
||||||
|
|
||||||
async def test_filtering_channels_for_removing_content(self):
|
async def test_filtering_channels_for_removing_content(self):
|
||||||
await self.channel_create('@some_channel', '0.1')
|
await self.channel_create('@some_channel', '0.1')
|
||||||
await self.stream_create('good_content', '0.1', channel_name='@some_channel', tags=['good'])
|
await self.stream_create('good_content', '0.1', channel_name='@some_channel', tags=['good'])
|
||||||
|
|
Loading…
Reference in a new issue