From a56d14086b2f443719e748cf77e13944616818ce Mon Sep 17 00:00:00 2001
From: Victor Shyba <victor.shyba@gmail.com>
Date: Wed, 4 Aug 2021 13:43:57 -0300
Subject: [PATCH] reflect media_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 524c11992..882050c0c 100644
--- a/lbry/wallet/server/db/writer.py
+++ b/lbry/wallet/server/db/writer.py
@@ -821,6 +821,7 @@ class SQLDB:
                (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,
+               (select cr.media_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_media_type,
                claim.*
         FROM claim LEFT JOIN claimtrie USING (claim_hash)
         WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
@@ -832,6 +833,7 @@ class SQLDB:
             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']
+            claim['media_type'] = claim.pop('reposted_media_type') or claim['media_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 f3a1ca6fc..9df8542eb 100644
--- a/tests/integration/blockchain/test_claim_commands.py
+++ b/tests/integration/blockchain/test_claim_commands.py
@@ -496,8 +496,8 @@ class ClaimSearchCommand(ClaimTestCase):
         # media_type
         await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])
         await self.assertFindsClaims([video], media_types=['video/mp4'])
-        await self.assertFindsClaims([image], media_types=['image/png'])
-        await self.assertFindsClaims([image, video], media_types=['video/mp4', 'image/png'])
+        await self.assertFindsClaims([repost, image], media_types=['image/png'])
+        await self.assertFindsClaims([repost, image, video], media_types=['video/mp4', 'image/png'])
 
         # duration
         await self.assertFindsClaim(video, duration='>14')