From 9dafd5f69bef707f81192e0bfb9b86f426cd52f5 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 11 Oct 2022 23:34:01 -0400 Subject: [PATCH] added claim_list filtering by reposted_claim_id and fix for claim_id of reposted claim in JSON output --- lbry/extras/daemon/daemon.py | 2 ++ lbry/schema/claim.py | 6 ++++++ tests/integration/claims/test_claim_commands.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index d11d7bab8..6604b0d41 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2409,6 +2409,7 @@ class Daemon(metaclass=JSONRPCServerType): Usage: claim_list [--claim_type=...] [--claim_id=...] [--name=...] [--is_spent] + [--reposted_claim_id=...] [--channel_id=...] [--account_id=] [--wallet_id=] [--has_source | --has_no_source] [--page=] [--page_size=] [--resolve] [--order_by=] [--no_totals] [--include_received_tips] @@ -2419,6 +2420,7 @@ class Daemon(metaclass=JSONRPCServerType): --channel_id= : (str or list) streams in this channel --name= : (str or list) claim name --is_spent : (bool) shows previous claim updates and abandons + --reposted_claim_id= : (str or list) reposted claim id --account_id= : (str) id of the account to query --wallet_id= : (str) restrict results to specific wallet --has_source : (bool) list claims containing a source field diff --git a/lbry/schema/claim.py b/lbry/schema/claim.py index 53565c1e1..22a385865 100644 --- a/lbry/schema/claim.py +++ b/lbry/schema/claim.py @@ -398,6 +398,12 @@ class Repost(BaseClaim): claim_type = Claim.REPOST + def to_dict(self): + claim = super().to_dict() + if claim.pop('claim_hash', None): + claim['claim_id'] = self.reference.claim_id + return claim + @property def reference(self) -> ClaimReference: return ClaimReference(self.message) diff --git a/tests/integration/claims/test_claim_commands.py b/tests/integration/claims/test_claim_commands.py index 1f0e15d47..9b475950f 100644 --- a/tests/integration/claims/test_claim_commands.py +++ b/tests/integration/claims/test_claim_commands.py @@ -1600,6 +1600,13 @@ class StreamCommands(ClaimTestCase): self.assertTrue(error['text'].startswith(f"Resolve of 'lbry://@some_channel#{some_channel_id[:1]}/bad_content#{bad_content_id[:1]}' was blocked")) self.assertTrue(error['censor']['short_url'].startswith('lbry://@blocking#')) + # local claim list still finds local reposted content that's blocked + claims = await self.claim_list(reposted_claim_id=bad_content_id) + self.assertEqual(claims[0]['name'], 'block1') + self.assertEqual(claims[0]['value']['claim_id'], bad_content_id) + self.assertEqual(claims[1]['name'], 'filter1') + self.assertEqual(claims[1]['value']['claim_id'], bad_content_id) + # a filtered/blocked channel impacts all content inside it bad_channel_id = self.get_claim_id( await self.channel_create('@bad_channel', '0.1', tags=['bad-stuff'])