From aee87693f853909632f4cec9156c6120fe6ef1e0 Mon Sep 17 00:00:00 2001
From: Victor Shyba <victor.shyba@gmail.com>
Date: Wed, 4 Aug 2021 11:41:44 -0300
Subject: [PATCH] reflect stream_type on repost searches

---
 lbry/wallet/server/db/writer.py                     | 2 ++
 tests/integration/blockchain/test_claim_commands.py | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lbry/wallet/server/db/writer.py b/lbry/wallet/server/db/writer.py
index 04be5bb60..524c11992 100644
--- a/lbry/wallet/server/db/writer.py
+++ b/lbry/wallet/server/db/writer.py
@@ -820,6 +820,7 @@ class SQLDB:
                (select group_concat(language, ' ') from language where language.claim_hash in (claim.claim_hash, claim.reposted_claim_hash)) as languages,
                (select cr.has_source from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_has_source,
                (select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
+               (select cr.stream_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_stream_type,
                claim.*
         FROM claim LEFT JOIN claimtrie USING (claim_hash)
         WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
@@ -830,6 +831,7 @@ class SQLDB:
             claim['censor_type'] = 0
             censoring_channel_hash = None
             claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source'])
+            claim['stream_type'] = claim.pop('reposted_stream_type') or claim['stream_type']
             for reason_id in id_set:
                 if reason_id in self.blocked_streams:
                     claim['censor_type'] = 2
diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py
index effc2542e..f3a1ca6fc 100644
--- a/tests/integration/blockchain/test_claim_commands.py
+++ b/tests/integration/blockchain/test_claim_commands.py
@@ -490,8 +490,8 @@ class ClaimSearchCommand(ClaimTestCase):
         # stream_type
         await self.assertFindsClaims([octet, unknown], stream_types=['binary'])
         await self.assertFindsClaims([video], stream_types=['video'])
-        await self.assertFindsClaims([image], stream_types=['image'])
-        await self.assertFindsClaims([image, video], stream_types=['video', 'image'])
+        await self.assertFindsClaims([repost, image], stream_types=['image'])
+        await self.assertFindsClaims([repost, image, video], stream_types=['video', 'image'])
 
         # media_type
         await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])