reflect media_type on repost searches

This commit is contained in:
Victor Shyba 2021-08-04 13:43:57 -03:00 committed by Victor Shyba
parent aee87693f8
commit a56d14086b
2 changed files with 4 additions and 2 deletions

View file

@ -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.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.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.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.* claim.*
FROM claim LEFT JOIN claimtrie USING (claim_hash) FROM claim LEFT JOIN claimtrie USING (claim_hash)
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog) WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
@ -832,6 +833,7 @@ class SQLDB:
censoring_channel_hash = None censoring_channel_hash = None
claim['has_source'] = bool(claim.pop('reposted_has_source') or claim['has_source']) 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['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: for reason_id in id_set:
if reason_id in self.blocked_streams: if reason_id in self.blocked_streams:
claim['censor_type'] = 2 claim['censor_type'] = 2

View file

@ -496,8 +496,8 @@ class ClaimSearchCommand(ClaimTestCase):
# media_type # media_type
await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream']) await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream'])
await self.assertFindsClaims([video], media_types=['video/mp4']) await self.assertFindsClaims([video], media_types=['video/mp4'])
await self.assertFindsClaims([image], media_types=['image/png']) await self.assertFindsClaims([repost, image], media_types=['image/png'])
await self.assertFindsClaims([image, video], media_types=['video/mp4', 'image/png']) await self.assertFindsClaims([repost, image, video], media_types=['video/mp4', 'image/png'])
# duration # duration
await self.assertFindsClaim(video, duration='>14') await self.assertFindsClaim(video, duration='>14')